Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are all Java SE classes available in Java ME?

Tags:

java

java-me

I'm a Java newbie. Wanted to know if all Java SE classes are available in Java ME. If not why is it so?

like image 215
gameover Avatar asked Nov 29 '22 06:11

gameover


2 Answers

No, only a subset is available, see http://java.sun.com/javame/technology/index.jsp for an introduction.

http://i.stack.imgur.com/doIiv.gif

A brief overview is given in this Wikipedia article:

Noteworthy limitations

Compared to the Java SE environment, several APIs are absent entirely, and some APIs are altered such that code requires explicit changes to support CLDC. In particular, certain changes aren't just the absence of classes or interfaces, but actually change the signatures of existing classes in the base class library. An example of this is the absence of the Serializable interface, which does not appear in the base class library due to restrictions on reflection usage. All java.lang.* classes which normally implement Serializable do not, therefore, implement this tagging interface.

Other examples of limitations depend on the version being used, as some features were re-introduced with version 1.1 of CLDC.

CLDC 1.0 and 1.1

  • The Serializable interface is not supported.
  • Parts of the reflection capabilities of the Java standard edition:
    • The java.lang.reflect package and any of its classes not supported.
    • Methods on java.lang.Class which obtain Constructors or Methods or Fields.
  • No finalization. CLDC does not include the Object.finalize() method.
  • Limited error handling. Non-runtime errors are handled by terminating the application or resetting the device.
  • No Java Native Interface (JNI)
  • No user-defined class loaders
  • No thread groups or daemon threads.
like image 199
Jerome Avatar answered Dec 05 '22 09:12

Jerome


It's worth noting that where J2ME versions of J2SE classes are apparently available, they often have a reduced API. So you can't always assume that code using 'available' classes will port straight over.

If memory serves, there are one or two methods with differening names too. Memory doesn't serve well enough right now to recall a specific example.

like image 40
martin clayton Avatar answered Dec 05 '22 10:12

martin clayton