I want to compile my code down to Java version 1.0.
I managed to compile down to 1.1
:
$ java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
$ javac -target 1.2 -source 1.2 MyClass.java
(works with some warnings)
$ javac -target 1.1 -source 1.2 MyClass.java
(works with some warnings)
But the target
option does not seem to accept 1.0
:
$ javac -target 1.0 -source 1.2 MyClass.java
javac: invalid target release: 1.0
How do I target JDK 1.0?
I want my .class and .jar file to work as many systems as possible, including very old ones, including JDK 1.0. (I don't have access to a system running JDK 1.0.)
What I've tried so far:
- Compiling with
ecj-3.0.2.jar
: It doesn't support-target 1.0
, the minimum is-target 1.1
. - Compiling with JDK 1.0: I couldn't run it, it wasn't released for Linux.
- Compiling with JDK 1.1: I couldn't run it, it wasn't released for Linux.
- Compiling with JDK 1.2: The Linux i386 javac binary doesn't work, it's giving me Segmentation fault.
- Compiling with JDK 1.3:
javac: invalid target release: 1.0
. - Compiling with JDK 1.4:
javac: invalid target release: 1.0
. - Compiling with JDK 1.5:
javac: invalid target release: 1.0
. This is the first JDK with Linux amd64 binaries. - Compiling with JDK 1.6:
javac: invalid target release: 1.0
. - Compiling with JDK 1.7:
javac: invalid target release: 1.0
. - Compiling with JDK 1.8:
javac: invalid target release: 1.0
. (I got this error first, when I asked the question.)
The reason why I believe that -target 1.0
may work is this answer: https://stackoverflow.com/a/26148408