2011-12-29 39 views
1

我目前安装了Java ME SDK 3.0.5并且正在从Eclipse运行MIDLET。J2ME仿真器在Eclipse中似乎不打开

当我运行模拟器设备我得到在控制台下面的数据在应用程序:

Syntax: 

emulator [arguments] 

In order to get commands supported by given device run: 
emulator.exe -Xdevice:<device name> -Xquery 

Generic list of arguments is: 

-version   Display version information about the emulator 
-help    Display list of valid arguments 
-classpath, -cp The class path for the VM 
-D<name>=<value> Set a system property 
-Xdebug   Use a remote debugger 
-Xrunjdwp:[transport=<transport>,address=<address>,server=<y/n>, 
     suspend=<y/n>] 
        Debugging options 
-Xdevice:<device> Select a device skin for the emulator 
-Xdomain:<domain_name> 
       Set the MIDlet suite's security domain 
-Xmain:<main class name> 
        Run the main method of a Java class, as in Java SE 
-Xquery   Print device information 

一切似乎是好了,但我不能得到任何形式的模拟的出现。

这里是我的MIDLET的代码,虽然我不认为问题出在这里。

import javax.microedition.midlet.MIDlet; 
import javax.microedition.midlet.MIDletStateChangeException; 
import javax.microedition.lcdui.*; 

public class Hello extends MIDlet implements CommandListener { 

private Command exitCommand; 
private Display display; 
private Form screen; 

public Hello() { 
display = Display.getDisplay(this); 

exitCommand = new Command ("Exit", Command.EXIT, 2); 

screen = new Form ("Hello World"); 

StringItem strItem = new StringItem ("","Hello World"); 
screen.append (strItem); 

screen.addCommand (exitCommand); 
screen.setCommandListener(this); 
} 

public void startApp() throws MIDletStateChangeException { 
    // set the current display to the screen 
    display.setCurrent(screen); 

} 

public void pauseApp() { 
    // TODO Auto-generated method stub 

} 


public void destroyApp(boolean unconditional) { 
    // TODO Auto-generated method stub 

} 


public void commandAction (Command c, Displayable s) 
{ 
    if (c == exitCommand) 
    { 
     destroyApp (false); 
     notifyDestroyed(); 
    } 
} 

} 

回答

3

输出非常简单,它告诉你模拟器的命令行语法不正确。

转到Java ME设备设置并编辑适合的仿真器命令行/启动选项。

切换IDE可能适合您作为短期修复程序,但最好找到问题的根源。另外它会帮助你理解模拟器框架。

1

我切换到NetBeans中,它集成了支持J2ME(而不是不必安装第三方的Eclipse插件),它现在的作品完美。

0

如果你喜欢冒险,并希望开发/无IDE的比我有一些希望的线运行的JavaME程序,写一个批处理脚本(或shell脚本用于Linux系统)与特定JAD手动运行该模拟器

批处理脚本(run.bat中)

"<javame-3.0-sdk-root-folder>\bin\emulator.exe" 
        -Xdescriptor:"<jad-filename-with-extension>" >> logs.txt 
pause 
exit 

保存上述脚本在同一文件夹中的应用程序JAD /罐。控制台打印将在log.txt文件中可用。

1

我在eclipse上运行一个基本的JavaMe应用程序时出现类似的问题,“Corrupt JAR,读取时出错”。在我参加了这个系列的首发http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.mtj.doc.user/html/gettingstarted/prepare_workbench.html之后,它对我很有效(尽量不要错过这里提到的任何东西)。
注意,当你启动应用程序,使用“发射作为模拟的Java ME JAD”( - 在右上角的“运行”页面上的部分)中的“应用描述符”( - 从左边的菜单。)

这是一个迟到的回复,但可能会在未来帮助某人。