Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to deal with the most common classes missing on J2ME
    primarykey
    data
    text
    <p>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.</p> <p>Keeping this core portable involves three drawbacks that I know of:</p> <ol> <li>Keeping to the old <strong>Java 1.4 syntax</strong>, not using any of the nice language features of Java 5.0</li> <li>only using <strong>external libraries</strong> 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)</li> <li>only using the <strong>classes which are present</strong> on all those platforms</li> </ol> <p>I know of ways to overcome <strong>(1)</strong>: code in 5.0 style and automatically convert it to 1.4 (<em>retroweaver</em> - haven't tried it yet, but seems ok).</p> <p>I think <strong>(2)</strong> is a problem that I just have to accept.</p> <p>Now I'd like to know what's the best workarround for <strong>(3)</strong>, especially collection classes, which I miss the most. I can think of those:</p> <ul> <li>Most programmers I know just don't use <code>Set</code>, <code>Map</code>, <code>List</code>, etc. and fallback to <code>Vector</code> and plain Arrays. I think this makes code ugly in the first place. But I also know that the right choice between <code>TreeSet/Hashset</code> or <code>LinkedList/ArrayList</code> is crucial for performance, and always using <code>Vector</code> and Arrays can't be right.</li> <li>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.</li> <li>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.</li> <li>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?</li> </ul> <p>Thanks for your answers and opinions!</p> <p><strong>Edit:</strong> 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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload