MIDP 2.0 版本问题:$type 的 $method 未定义

发布于 2024-08-24 18:01:51 字数 911 浏览 3 评论 0原文

我编写了一个 MIDlet,它可以执行几项“高级”操作:从 Web 获取图像、调整图像大小、将图像保存在手机上、显示图像。

这一切在诺基亚 S60 第三版 FP1 模拟器中都能完美运行。该设备支持 MIDP 2.0 和 CLDC 1.1(还有 JSR75,我需要它来保存文件)。它在诺基亚 E71(物理设备)上也能正常工作。

然后我尝试在其他几个模拟器上运行 MIDlet。其中之一是 Java ME SDK 3.0 中的 DefaultCldcJtwiPhone2,也声称支持 MIDP 2.0 和 CLDC 1.1。它没有 JSR75,这解释了为什么“FileConnection 无法解析为类型”。

然而,这并不能解释为什么 List.deleteAll()、String.equalsIgnoreCase(String) 和其他一些未定义。

我得到的实际错误:

  • Math 类型的方法 ceil(double) 未定义
  • List 类型的方法 deleteAll() 未定义 String
  • 类型的方法 equalsIgnoreCase(String) 未定义
  • getWidth() 方法未定义 Displayable 类型

当我查看 MIDP 2.0(即 JSR118)API 时 (http:// /java.sun.com/javame/reference/apis/jsr118/),我可以清楚地看到所有这些方法都存在,“since”标签是 MIDP 2.0 或 CLDC 1.1。

我的问题:为什么支持 MIDP 2.0 的模拟器不能访问所有 MIDP 2.0 方法?或者,我做错了什么?

I've written a MIDlet that does several "advanced" things: fetching images from the web, resizing them, saving them on the phone, displaying them.

This all works perfectly in the Nokia S60 3rd Edition FP1 emulator. This device has MIDP 2.0 and CLDC 1.1 support (also JSR75, which I need in order to save files). It also works as it should on the Nokia E71 (physical device).

I then tried to run the MIDlet on several other emulators. One of them, the DefaultCldcJtwiPhone2 from the Java ME SDK 3.0, also claims MIDP 2.0 and CLDC 1.1 support. It doesn't have JSR75, which explains why "FileConnection can not be resolved to a type".

This does not, however, explain why List.deleteAll(), String.equalsIgnoreCase(String) and a few others are undefined.

The actual errors that I get:

  • The method ceil(double) is undefined for the type Math
  • The method deleteAll() is undefined for the type List
  • The method equalsIgnoreCase(String) is undefined for the type String
  • The method getWidth() is undefined for the type Displayable

When I look at the MIDP 2.0 (i.e. JSR118) API (http://java.sun.com/javame/reference/apis/jsr118/), I can clearly see all of these methods being present, with the "since" tag being either MIDP 2.0 or CLDC 1.1.

My question: why doesn't an emulator with MIDP 2.0 support have access to all MIDP 2.0 methods? Or alternatively, what am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤千羽 2024-08-31 18:01:52

听起来您正在使用 CLDC 1.1 中定义的方法;您使用的模拟器必须仅支持 CLDC 1.0(这肯定可以解释缺少 equalsIgnoreCase() 以及涉及 doublefloat 原语的任何内容) 。请在此处查看完整的 API。请参阅此处了解 1.0 之间的差异列表和1.1。

编辑:
检查设备 CLDC 版本的一些方法:

1) 按照 这里

System.out.println("The CLDC version is:  " + System.getProperty("microedition.configuration"));

2) 检查是否存在仅在1.1中支持的类。

try {
    Class.forName("java.lang.ref.WeakReference");
    System.out.println("It's CLDC 1.1");
} catch (ClassNotFoundException e) {
    System.out.println("It's CLDC 1.0");
}

Sounds like you're using methods defined in CLDC 1.1; the emulator you are using must only support CLDC 1.0 (this would certainly explain the lack of equalsIgnoreCase() and anything involving double and float primitives). See the full API here. And see here for a list of differences between 1.0 and 1.1.

EDIT:
Some ways to check the CLDC version of your device:

1) Check the microedition.configuration system property as described here.

System.out.println("The CLDC version is:  " + System.getProperty("microedition.configuration"));

2) Check the existence of a class supported only in 1.1.

try {
    Class.forName("java.lang.ref.WeakReference");
    System.out.println("It's CLDC 1.1");
} catch (ClassNotFoundException e) {
    System.out.println("It's CLDC 1.0");
}
一杯敬自由 2024-08-31 18:01:52

Eclipse 引用 cldc_1.0.jar 和 cldc_1.1.jar(以及 midp_2.0.jar 和 midp_2.1.jar)。

要修复它:
转到窗口>首选项> Java ME>设备管理>> 您的设备 >编辑...>>图书馆> cldc_1.0.jar >删除

您可以在此处找到更多详细信息: http ://thompsonng.blogspot.com/2009/09/j2me-setting-eclipse-to-use-cldc-11.html

Eclipse references both cldc_1.0.jar and cldc_1.1.jar (as well as midp_2.0.jar and midp_2.1.jar).

To fix it:
Go to Window > Preferences > Java ME > Device Managment > your-device > Edit... > Libraries > cldc_1.0.jar > Remove

More details you can find here: http://thompsonng.blogspot.com/2009/09/j2me-setting-eclipse-to-use-cldc-11.html

黑色毁心梦 2024-08-31 18:01:52

即使您选择了支持 CLDC-1.1 的模拟器设备(例如 DefaultCldcJtwiPhone2),您仍然可以将其配置为模拟仅 CLDC-1.0 的手机。

至少 Netbeans 上的项目属性是这样的。

Even after you have chosen an emulator device that supports CLDC-1.1 , like DefaultCldcJtwiPhone2, you can still configure it to emulate a CLDC-1.0 only phone.

At least that's what the project properties on Netbeans look like.

早乙女 2024-08-31 18:01:52

今天(11/03/10)更新后我遇到了同样的问题:
SDK 1.6.0_17 + eclipse ee 3.5.1 + Java_ME_platform_SDK_3.0 EA。
到:
SDK 1.6.0_18 + eclipse ee 3.5.2 + Java_ME_platform_SDK_3.0。

对于 Math 类型,方法 ceil(double) 未定义
Math 类型的方法 Floor(double) 未定义
Math 类型中的方法 abs(int) 不适用于参数 (double)
对于 Math 类型,方法 sqrt(double) 未定义

I got the same problem today(11/03/10) after updating from:
SDK 1.6.0_17 + eclipse ee 3.5.1 + Java_ME_platform_SDK_3.0 EA.
to:
SDK 1.6.0_18 + eclipse ee 3.5.2 + Java_ME_platform_SDK_3.0.

The method ceil(double) is undefined for the type Math
The method floor(double) is undefined for the type Math
The method abs(int) in the type Math is not applicable for the arguments (double)
The method sqrt(double) is undefined for the type Math

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文