4

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?

benvd
  • 5,776
  • 5
  • 39
  • 59
  • Are you using an IDE or just the Java ME SDK? – michael aubert Mar 10 '10 at 11:00
  • I'm using Eclipse. See my comment on your answer. – benvd Mar 10 '10 at 12:10
  • I "solved" the problem. So, when I changed the target device in the Application Descriptor (config file, might be specific to the Eclipse J2ME environment), a CLDC 1.1 emulator doesn't get recognized as such. It turns out that it does work correctly when I create a new debug (or run) configuration, where I can set the emulator to the one I want... – benvd Mar 10 '10 at 12:57
  • eclipse bug? you might want to check whether the people in charge know about it already. – michael aubert Mar 11 '10 at 14:21

4 Answers4

1

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");
}
funkybro
  • 8,432
  • 6
  • 39
  • 52
  • Yeah, those methods are indeed part of CLDC 1.1, I'm aware of the differences. I mentioned that the emulators I'm testing on do support CLDC 1.1, so I shouldn't be having these problems. Unless the emulators really only support CLDC 1.0...? – benvd Mar 10 '10 at 09:51
  • I reckon your emu is telling lies! Answer edited to include some ways of telling for sure. – funkybro Mar 10 '10 at 10:02
  • I made a new project and added the System.getProperty line, but it printed out "The CLDC version is: CLDC-1.1". Trying to build my real project with the exact same emulator still brings up the same errors. – benvd Mar 10 '10 at 10:56
  • Displayable isn't in CLDC, is it? – michael aubert Mar 10 '10 at 11:04
  • "Trying to build my real project with the exact same emulator still brings up the same errors." So you get the error when building rather than at runtime? – funkybro Mar 10 '10 at 11:24
  • Displayable.getWidth() is MIDP2.0, not 1.0. – funkybro Mar 10 '10 at 11:29
  • @QuickRecipesOnSymbianOS: no, but it is in MIDP @funkybro: Yep, when building. – benvd Mar 10 '10 at 11:57
1

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

epox_spb
  • 11
  • 1
0

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.

michael aubert
  • 6,836
  • 1
  • 16
  • 32
  • I'm using Eclipse, but the configuration for my project is set to CLDC 1.1, and the device properties indicate CLDC 1.1 as well. – benvd Mar 10 '10 at 12:06
0

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