Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 897291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:51:49+00:00 2026-05-15T14:51:49+00:00

I’m trying to code an application which runs un different java platforms like J2SE,

  • 0

I’m trying to code an application which runs un different java platforms like J2SE, J2ME, Android, etc. I already know that I’ll have to rewrite most of the UI for each platform, but want to reuse the core logic.

Keeping this core portable involves three drawbacks that I know of:

  1. Keeping to the old Java 1.4 syntax, not using any of the nice language features of Java 5.0
  2. only using external libraries that are known to work on those platforms (that is: don’t use JNI and don’t have dependencies to other libs which violate this rules)
  3. only using the classes which are present on all those platforms

I know of ways to overcome (1): code in 5.0 style and automatically convert it to 1.4 (retroweaver – haven’t tried it yet, but seems ok).

I think (2) is a problem that I just have to accept.

Now I’d like to know what’s the best workarround for (3), especially collection classes, which I miss the most. I can think of those:

  • Most programmers I know just don’t use Set, Map, List, etc. and fallback to Vector and plain Arrays. I think this makes code ugly in the first place. But I also know that the right choice between TreeSet/Hashset or LinkedList/ArrayList is crucial for performance, and always using Vector and Arrays can’t be right.
  • I could code my own implementations of that classes. This seems to be reinventing the wheel, and I think I could not do it as good as others have done.
  • Since Java is open source, I could grab the sourcecode of the J2SE Collections framework and include into my application when building for J2ME. I don’t know if this is a good idea, though. Pherhaps there are good reasons not to do this.
  • Maybe there already are libraries out there, which rebuild the most important features of the collections framework, but are optimized for low end systems, pherhaps by not implementing functionality that is used infrequently. Do you know any?

Thanks for your answers and opinions!

Edit: I finally found a (complex, but nice) solution, and I thought by providing my own answer and accepting it, the solution would become visible at the top. But to the contrary, my answer is still at the very bottom.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:51:49+00:00Added an answer on May 15, 2026 at 2:51 pm

    It’s been a while since I asked this question, and I while since I found a nice, working solution for the problem, but I had since forgotton to tell you.

    My main focus was the Java Collections Framework, which is part of the java.util package.

    I’ve finally taken the source code of Suns Java 6.0 and copied all the classes that belong to the Collections framework into a project of my own. This was a Java 6.0 project, but I used the jars from J2ME as classpath. Most of those classes that I copied depend on other J2SE classes, so there are broken dependencies. Anyway, it was quite easy to cut those depensencies by leaving out everything that deals with serialization (which is not a priority for me) and some minor adjustments.

    I compiled the whole thing with a Java 6 compiler, and retrotranslator was used to port the resulting bytecode back to Java 1.2.

    Next problem is the package name, because you can’t deliver classes from java.util with a J2ME application and load them – the bootstrap class loader won’t look into the applications jar file, the other bootloaders aren’t allowed to load something with that package name, and on J2ME you can’t define custom classloaders. Retrotranslator not only converts bytecode, it also helps to change name references in existing bytecode. I had to move and rename all classes in my project, e.g. java.util.TreeMap became my.company.backport.java.util.TreeMap_.

    I was than able to write actual J2ME application in a second Java 6.0 project which referenced the usual java.util.TreeMap, using the generic syntax to create type-safe collections, compile that app to Java 6.0 byte code, and run it through retrotranslator to create Java 1.2 code that now references my.company.backport.java.util.TreeMap_. Note that TreeMap is just an example, it actually works for the whole collections framework and even for 3rd party J2SE Jars that reference that framework.

    The resulting app can be packaged as a jar and jad file, and runs fine on both J2ME emulators and actual devices (tested on a Sony Ericsson W880i).

    The whole process seems rather complex, but since I used Ant for build automation, and I needed retranslator anyway, there only was a one-time overhead to setup the collection framework backport.

    As stated above, I’ve done this nearly a year ago, and writing this mostly from the top of my head, so I hope there are no errors in it. If you are interested in more details, leave me a comment. I’ve got a few pages of German documentation about that process, which I could provide if there is any demand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ok, well first thing is to point out that the… May 16, 2026 at 8:33 am
  • Editorial Team
    Editorial Team added an answer What about another possibility: char charArray3[] = {102, 111, 111,… May 16, 2026 at 8:33 am
  • Editorial Team
    Editorial Team added an answer Well, $row only contains one row so.... $items = mysqli_num_rows($result)… May 16, 2026 at 8:33 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.