Straightforward java compilation on termux

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

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

2 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(ClasspathLocation.java:129)
    at org.eclipse.jdt.internal.compiler.batch.FileSystem.initializeModuleLocations(FileSystem.java:222)
    at org.eclipse.jdt.internal.compiler.batch.FileSystem.(FileSystem.java:212)
    at org.eclipse.jdt.internal.compiler.batch.Main.getLibraryAccess(Main.java:3447)
    at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:4631)
    at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1771)
    at org.eclipse.jdt.internal.compiler.batch.Main.main(Main.java:1479)
    “` 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?

    Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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