Recently, I need to port MIDP to my project. I searched for it online. Basically, we recommend using JDK 1.4 to compile JDK, or directly compiling JDK 1.6 to version 1.4, which is actually version 1.4, an error occurs when compiling with 1.6 directly. In this way, some applications compiled with 1.6 are used. Program It may not be able to run smoothly on it.
No way, so you have to modify it according to the compilation error prompt.
1. Compile cldc first, and modify version 01.04 to version 1.1 as described in other documents.
The most common compilation error is that the "stringbuider" class cannot be found. This is because after jdk1.5, "stringbuilder" is used to replace the "stringbuffer" class. The interfaces are basically the same. The difference is that the former is thread-safe, and the latter is only suitable for single-threaded environments. By looking at the jdk1.6 source code, it is found that stringbuilder involves too many classes and is not suitable for direct migration to MIDP, so the modification workload will be huge. Because the thread security issue is not important in the project, after comparing the source code of the two, I decided to directly use stringbuffer to transform it to stringbuider. Replace "stringbuffer" with "stringbuider" and recompile cldc. There are only three errors because sringbuilder. java declares three native functions: Public native string tostring (), Public native stringbuilder append (int I), and public native synchronized stringbuffer append (string Str ). Code Link error. Change them directly to Java functions, remove native, add the definition, and finished.
In addition, stirng. Java does not use stringbuilder as a constructor, and only stringbuffer is used as a parameter. Add a constringbuffer Public String (stringbuffer.
In classreader. Java, Enum is used as the variable name. In jdk1.6, Enum exists as a keyword and cannot be a variable name. Modify the file to enmu1. The file is OK.
2. Compile MIDP.
After cldc is compiled, MIDP is easy. There are two more errors. Locate the error according to the error prompt:
At datefield. Java and ln160, The Condition Statement is directly split into if statements.
Form. Java, ln2092, directly split the condition statement into the if statement.
Then compile OK.
Run the Java program. Complete cldc1.1/midp2.0.