Straightforward java compilation on termux

To run java apps on your android device, install termux, and run the following:

$ pkg install ecj dx
$ cat > <<EOF
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello world, on termux!");
$ ecj
$ dx --dex --output=Hello.dex Hello.class
$ dalvikvm -cp Hello.dex Hello
Hello world, on termux!

5 Replies to “Straightforward java compilation on termux”

  1. Hey, so, this error pops up:
    java.lang.NoClassDefFoundError: org.eclipse.jdt.internal.compiler.batch.-$$Lambda$ClasspathLocation$GQimjP-835AJ59yLyUnQopLF5GE
    at org.eclipse.jdt.internal.compiler.batch.ClasspathLocation.getModuleNames(
    at org.eclipse.jdt.internal.compiler.batch.FileSystem.initializeModuleLocations(
    at org.eclipse.jdt.internal.compiler.batch.FileSystem.(
    at org.eclipse.jdt.internal.compiler.batch.Main.getLibraryAccess(
    at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(
    at org.eclipse.jdt.internal.compiler.batch.Main.compile(
    at org.eclipse.jdt.internal.compiler.batch.Main.main(
    “` after trying to do this on termux. I did all of the commands until the ecj one, because it doesnt work after this. any help?


  2. Thank you, thank you, thank you… this is just what I was looking for. I had a script that used am start to launch Java-NIDE and had to push the compile button… to gen my class / dex files.. and yet another to add the generated dex files to my CLASSPATH.


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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s