Compiling Java (SE, ME) in PocketPC with PhoneME

Posted on Updated on

As I promised earlier I try to find a free method to compile java sources on PDA including Java SE and Java ME. In my earlier post I succesfully compiled Java SE and ME code with CrE-ME.

How to compile

I’m used precompiled version of PhoneME as a JVM and cke as text editor.

To compile with make some batch file (%1 is the fullname of the source, %2 is the fullpath):

@echo \phoneme\foundation\bin\cvm -cp "\jar\tools.jar;\jar\rt.jar;%2\" %1
@\phoneme\foundation\bin\cvm -cp "\jar\tools.jar;\jar\rt.jar;%2\" %1


@echo \phoneme\foundation\bin\cvm -cp "\jar\tools.jar;\jar\rt.jar;\JAR\midpapi10.jar;\JAR\cldcapi10.jar;%2\" %1
@\phoneme\foundation\bin\cvm -cp "\jar\tools.jar;\jar\rt.jar;\JAR\midpapi10.jar;\JAR\cldcapi10.jar;%2\" %1


You can compile and run your compiled class:

Compile \srcpath\ \srcpath

\phoneme\foundation\bin\cvm \srcpath\hello

It seems to me that running the compiled MIDP is more compilcated, you should install your midlet *.jar first then run with the MIDPLauncher. You can install a midlet within the GUI, but it’s frustrating as you can’t use copy/paste, or this command line installer:


if not %1X == X goto run_midlet
@echo off
echo .
echo Usage: installMidlet ^<URL^> [^<URL label^>]
echo .
goto :EOF

cd \phoneme\midp\bin\arm\runMidlet -1 com.sun.midp.scriptutil.CommandLineInstaller I %1 %2

I believe somehow we can run our classes without jar’ing but how. However it seems to me that you can run your midlet from the command line only if you know it’s position in the MidletLauncher:


cd \phoneme\midp\bin\arm\runMidlet %1

Example: RunMidlet 2 will start the second installed MIDP.

isJavaLetterOrDigit(C) error

You may encounter a serius error while compiling Java ME source code:

java.lang.NoSuchMethodError: java.lang.Character: method isJavaLetterOrDigit(C)Z not found
at Source)

In JavaDocs I found this:

public static boolean isJavaLetterOrDigit(char ch)
Deprecated. Replaced by isJavaIdentifierPart(char).

Determines if the specified character is a “Java” letter or digit, that is, the character is permissible as a non-initial character in an identifier in the Java language.

A character is considered to be a Java letter or digit if and only if it is a letter, a digit, the ASCII dollar sign character '$', or the underscore character '_'.

On this arcticle:

The pages and recommend using the compiler in the J2SE 1.1 classes to compile with For Java 1.3.1 that would be tools.jar, giving you

java -cp tools.jar Unfortunately, that does not work with Java 1.3.1. The J2SE compiler uses Character.isJavaLetterOrDigit, which in J2ME has been replaced by Character.isJavaIdentifierPart. And since Sun does not distribute the java sources of their compiler, we can’t fix it.


Use the Eclipse‘s JDT Compiler named ecj.jar.

@echo \phoneme\foundation\bin\cvm -jar \java\ecj\ecj.jar -cp \jar\midpapi20.jar;\jar\cldcapi11.jar;%2\ %1
@\phoneme\foundation\bin\cvm -jar \java\ecj\ecj.jar -cp \jar\midpapi20.jar;\jar\cldcapi11.jar;%2\  %1

Configuring cke to compile


Program: \Windows\CMD.exe

Arguments: /c “\Compile.bat” “$fullname” \$filepath 1>”$filepath\$filename.log” 2>”$filepath\$filename.err”

[X] Save actual document


Program: \Windows\CMD.exe

Arguments: /c “\ecj.bat” “$fullname” \$filepath 1>”$filepath\$filename.log” 2>”$filepath\$filename.err”

[X] Save actual document


Q: Compiling with ecj.jar will cause an error

cannot read the source from <> either the file uses a different than utf-8 or it is corrupted

A: Use only English characters (avoid á, é, ő, ú, ű, í etc even in commented lines)

Q: How to preverify all the classes? This process is necessary in case of MIDP.

A: I don’t know, maybe Eclipse has a equivalent java bytecode? Update: read this post!

Q: How to make jar and jad file?

A: I don’t know, maybe TotalCommander can zip, add manifest file and rename it. Edit jad manually.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s