Linus Fernandes
Linus Fernandes

Reputation: 496

Compiling with ecj on Termux fails lambda expressions

Compiling with ecj on Termux produces the following error message:

Lambda expressions are allowed only at source level 1.8 or above.

No options were specified when running the tool.

Compiling with switch - 1.8 produces the following output:

ecj -1.8 Composite2

duplicate compliance setting specification: -1.8

Composite2 is the directory where my source code resides.

I tried the following next:

ecj -source 1.8 -target 1.8 Composite2

Compliance level '1.7' is incompatible with source level '1.8'. A compliance level '1.8' or better is required.

The source is available here

Are there any settings or switches I'm missing? I'm unfamiliar with using ecj as a compiler.

Can you help?

There appears to be solutions like Retro Lambda and backporting to make Java 8 source work on 7 or earlier. I have yet to try it though. There's only so much one person can check out. ( See comments below for clarifications).


A workaround might be to install Arch Linux on Termux.. The command prompt can be a bit buggy, though.

You can then install Open JDK 8 and eclipseecj using the package manager pacman.

That worked; ecj now compiles 1.8 code.

I wished to avoid installing the full JDK since it introduces redundancies and consumes additional space.

Upvotes: 0

Views: 694

Answers (2)

Linus Fernandes
Linus Fernandes

Reputation: 496

Termux on Android 7 does not support any java versions beyond 7. ARCH Linux on Termux supports up to Java 13. The best option is to install OpenJDK on Arch Linux for Termux and use javac as against ecj. There are other issues with ecj on Arch Linux as well such as support only till Java 8.

Upvotes: 1

S D Rausty
S D Rausty

Reputation: 9

This appears to be a bug in ecj that was reported https://bugs.eclipse.org/bugs/show_bug.cgi?id=535969 here, and patched https://bugs.eclipse.org/bugs/show_bug.cgi?id=477894 here.

Verified with Eclipse 4.9 m2 Build id: I20180731-0800

Upvotes: 0

Related Questions