Jdk1.6 compiling cldc1.1/midp2.0

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.