With eclipse I get the following error when I execute an ant task with Java 1.8.
JRE version less than 11 is not supported.
My "external tool configuration" is configured with "Seperate JRE" Eclipse Adoptium jdk-8.0.352.8-hotspot
Anybody knows how to prevent this restriction?
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components) Version: 2022-12 (4.26.0) Build id: 20221201-1913
Got it running.
Adding source and target with 1.8 did the trick for me in build.xml
<JAVAC destdir="${build.classes.test}" source="1.8" target="1.8"> <src path="${src.test}" />
Afterwards I checked with javap -v MyStuff.class
and saw Output major version: 52
which is 1.8
Here are bugs describing the situation:
java task is not running with 1.8
The above method worked for the the ant javac
task. But I had also ant java
to generate some classes. I ended up with
[java] Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
Because Ant is running with Java 17 and JAXB classes like javax.xml.bind.JAXBException
are not included in JDK anymore since Java 11.
My workaround is to not use Eclipse for these ant tasks but to use a seperate (old=same we use in jenkins build) ant installation and run tasks from command line. See https://ant.apache.org/manual/install.html#getBinary
running ant task with 1.8 leads to Error: A JNI error has occurred, please check your installation and try again.