Can Java SE class libraries be used on mobile devices?
I am relatively new to Java, and am developing a Java implementation of a class library I have already written in .NET and Objective-C. The library in Java is primarily being aimed at Android devices (or any device which supports开发者_运维技巧 Java) - would a standard Java SE library be compatible with Java ME? The only data types being used are the standard base types, including String, and possibly StringBuffer from the java.text package.
You'll have to look exactly at the class library present on each specific target device. There are different Java ME profiles, and Android is something else entirely (has nothing to do with Java ME). But the classes of java.lang
(and that's where StringBuffer
lives, not java.text
) are of course present on all of them.
Android is mostly Java SE with a few Android extensions. But it sounds like your use case will work fine.
The compatibility of the library would depend on what does it actually use from Java API. Bear in mind that some classes that exist in both SE and ME don't have the same set of methods (i.e. ME has less).
As a general case, I'd say the answer is no, however the best way to find out is to actually try.
Also, as a sidenote:
If you need the library for some heavy lifting operations, it might not be wise to do that on the mobile device. If your app is supposed to communicate with a server, you'll probably want to put more resource-heavy operations there. Another benefit of that design is that the server side application is using Java SE and may use any Java library whatsoever.
精彩评论