Java 如何使用 Eclipse 为诺基亚创建 J2ME midlets
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/62491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create J2ME midlets for Nokia using Eclipse
提问by Asaf R
Nokia has stopped offering its Developer's Suite, relying on other IDEs, including Eclipse. Meanwhile, Nokia changed its own development tools again and EclipseMe has also changed. This leaves most documentation irrelevant.
诺基亚已停止提供其开发人员套件,而是依赖于其他 IDE,包括 Eclipse。与此同时,诺基亚再次改变了自己的开发工具,EclipseMe 也发生了变化。这使得大多数文档变得无关紧要。
I want to know what does it take to make a simple Hello-World?
我想知道制作一个简单的 Hello-World 需要什么?
(I already found out myself, so this is a Q&A for other people to use)
(我已经发现了自己,所以这是一个供其他人使用的问答)
采纳答案by Asaf R
Here's what's needed to make a simple hello world -
这是制作一个简单的 hello world 所需的东西 -
- Get EclipseIDE for Java. I used Ganymede. Set it up.
- Get Sun's Wireless Toolkit. I used 2.5.2. Install it.
- Get Nokia's SDK (found here), in my case for S40 6230i Edition, and install it choosing the option to integrate with Sun's WTK
- Follow the instructions at http://www.eclipseme.org/to download and install Mobile Tools Java (MTJ). I used version 1.7.9.
- When configuring devices profiles in MTJ (inside Eclipse) use the Nokia device from the WTK folder and NOT from Nokia's folder.
- Set the WTK root to the main installation folder - for instance c:\WTK2.5.2; Note that the WTK installer creates other folders apparently for backward compatibility.
- Get Antennaand set its location in MTJ's property page (in Eclipse).
- 获取Java 的EclipseIDE。我用过木卫三。设置它。
- 获取 Sun 的无线工具包。我用的是 2.5.2。安装它。
- 获取诺基亚的 SDK(在这里找到),在我的情况下是 S40 6230i 版,并选择与 Sun 的 WTK 集成的选项进行安装
- 按照http://www.eclipseme.org/上的说明下载并安装 Mobile Tools Java (MTJ)。我使用的是 1.7.9 版。
- 在 MTJ(在 Eclipse 内)中配置设备配置文件时,请使用 WTK 文件夹中的诺基亚设备,而不是诺基亚文件夹中的设备。
- 将 WTK 根目录设置为主安装文件夹 - 例如 c:\WTK2.5.2;请注意,WTK 安装程序创建其他文件夹显然是为了向后兼容。
- 获取Antenna并在 MTJ 的属性页面(在 Eclipse 中)设置其位置。
Here's an HelloWorld sample to test the configuration.
Note: It worked for me on WindowsXP. Also note: This should work for S60 as well. Just replace the S40 SDK in phase 3 with S60's.
注意:它在 WindowsXP 上对我有用。另请注意:这也适用于 S60。只需将阶段 3 中的 S40 SDK 替换为 S60。
回答by Brad Richards
Unless you need to do something Nokia-specific, I suggest avoiding the Nokia device definitions altogether. Develop for a generic device, then download your application to real, physical devices for final testing. The steps I suggest:
除非您需要执行特定于诺基亚的操作,否则我建议您完全避免使用诺基亚设备定义。针对通用设备进行开发,然后将您的应用程序下载到真实的物理设备上进行最终测试。我建议的步骤:
Download and install Sun's Wireless Toolkit.
Install EclipseME, using the method "installing via a downloaded archive".
Configure EclipseME. Choose a generic device, such as the "DefaultColorPhone" to develop on.
Create a new project "J2ME Midlet Suite"
Right-click on the project, and create a new Midlet "HelloWorld"
Enter the code, for example:
下载并安装 Sun 的无线工具包。
安装 EclipseME,使用方法“通过下载的存档安装”。
配置 EclipseME。选择通用设备,例如“DefaultColorPhone”进行开发。
创建一个新项目“J2ME Midlet Suite”
右键单击该项目,并创建一个新的 Midlet “HelloWorld”
输入代码,例如:
public HelloWorld() {
super();
myForm = new Form("Hello World!");
myForm.append( new StringItem(null, "Hello, world!"));
myForm.addCommand(new Command("Exit", Command.EXIT, 0));
myForm.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(myForm);
}
protected void pauseApp() {}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {}
public void commandAction(Command arg0, Displayable arg1) {
notifyDestroyed();
}
回答by Stepan Stolyarov
The most annoying issue with EclipseME for me was the "broken" debugger, which just wouldn't start. This is covered in docs, but it took me about an hour to find this tip when I first installed EclipseME, and another hour when I returned to JavaME development a year later, so I decided to share this piece of knowledge here, too.
对我来说,EclipseME 最烦人的问题是“损坏的”调试器,它无法启动。这在文档中有介绍,但是当我第一次安装 EclipseME 时我花了大约一个小时才找到这个提示,一年后我回到 JavaME 开发又花了一个小时,所以我决定也在这里分享这块知识。
If the debugger won't start,
如果调试器无法启动,
- open "Java > Debug" section in Eclipse "Preferences" menu, and uncheck "Suspend execution on uncaught exceptions" and "Suspend execution on compilation errors" and
- increase the "Debugger timeout" near the bottom of the dialog to at least 15000 ms.
- 在 Eclipse“首选项”菜单中打开“Java > 调试”部分,并取消选中“在未捕获的异常上暂停执行”和“在编译错误时暂停执行”和
- 将对话框底部附近的“调试器超时”增加到至少 15000 毫秒。
After that, Eclipse should be able to connect to KVM and run a midlet with a debugger attached.
之后,Eclipse 应该能够连接到 KVM 并运行带有调试器的 midlet。