Are all Java SE classes available in Java ME?

旧城冷巷雨未停 提交于 2019-12-23 12:36:38

问题


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


回答1:


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

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.



回答2:


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.




回答3:


No, Java ME is a significantly restricted subset of Java SE. Java SE is an enormous standard library, and most of the devices Java ME is intended to run on don't have the resources to support all that overhead.

Take a look at the javadocs for CLDC 1.1, the main, universally supported API accessible to Java ME.




回答4:


No they are not. The reason for this is the standard library is quite large, making it difficult to use on embedded devices with small amounts of memory and slower processors.

See this page for more info about whats included and whats not.



来源:https://stackoverflow.com/questions/1985360/are-all-java-se-classes-available-in-java-me

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!