MIDP 2.0 issues: $ method undefined for $ type

I wrote a MIDlet that does a few “advanced” things: selecting images from the Internet, resizing them, saving them on the phone, displaying them.

All this works fine in the Nokia S60 3rd Edition FP1 emulator. This device supports MIDP 2.0 and CLDC 1.1 (also JSR75, which I need to save files). It also works the same as it does on the Nokia E71 (physical device).

Then I tried to run MIDlet on several other emulators. One of them, DefaultCldcJtwiPhone2 from the Java ME SDK 3.0, also claims support for MIDP 2.0 and CLDC 1.1. It does not have a JSR75 that explains why "FileConnection cannot be allowed for a type."

This, however, does not explain why List.deleteAll (), String.equalsIgnoreCase (String), and some other undefined.

Actual errors I get:

  • Ceil (double) undefined method for type Math
  • The deleteAll () method is undefined for the type List
  • EqualsIgnoreCase (String) undefined method for type String
  • GetWidth () method - undefined for type Displayable

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

My question is : why does a MIDP 2.0 emulator not have access to all MIDP 2.0 methods? Or, alternatively, what am I doing wrong?

+4
source share
4 answers

It looks like you are using the methods defined in CLDC 1.1; The emulator you use should only support CLDC 1.0 (this, of course, explains the absence of equalsIgnoreCase() and everything related to the primitives double and float ). Full API API is here . And look here for a list of the differences between 1.0 and 1.1.

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

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

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

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

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

Eclipse refers to cldc_1.0.jar and cldc_1.1.jar (as well as midp_2.0.jar and midp_2.1.jar).

To fix this: Go to "Window"> "Settings"> "Java ME"> "Device Management"> "your device"> "Edit"> "Libraries"> cldc_1.0.jar> "Delete"

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

+1
source

Even after you select an emulator that supports CLDC-1.1, for example DefaultCldcJtwiPhone2, you can still configure it to emulate only CLDC-1.0.

At least what Netbeans project properties look like.

0
source

I have 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. so that: SDK 1.6.0_18 + eclipse ee 3.5.2 + Java_ME_platform_SDK_3.0.

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

0
source

Source: https://habr.com/ru/post/1303646/


All Articles