warning: [options] bootstrap class path not set in conjunction with -source 1.5
bootclasspath usage
javac -bootclasspath /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar \
-source 1.7 Main.java
On UNIX systems, locate rt.jar
using:
locate -r '/rt.jar$'
Set JAVA_HOME
so that rt.jar
is located at $JAVA_HOME/jre/lib/rt.jar
, then:
javac -source 1.7 -bootclasspath "$JAVA_HOME/jre/lib/rt.jar" Main.java
Tested on Ubuntu 14.04 for Oracle Java 7 and 8.
I'm currently running Netbeans IDE 8.0.2 with JDK 1.8 on Linux Mint 17.1 which has java -version = 1.7.0_65. So to be able to run JAR files I had to set myProject>Properties>Source/Binary Format: JDK 7. However when building (myProject>Clean and Build) I got a similar warning: warning: [options] bootstrap class path not set in conjunction with -source 1.7.
The solution was to add the Linux Mint JDK1.7 platform to the Netbeans platform list.
This can be done by going to myProject>Properties>Libraries and clicking the Manage Platforms... button. Then in the Java Platform Manager window click Add Platform... and select: Java Standard Edition, click Next and browse to /usr/lib/jvm/java-7-openjdk-amd64 (or whatever is the location of the JDK 1.7 version). The Platform name will be set to JDK1.7. Just click Finish and you're done.
You can now select the Java platform in the project properties. By selecting JDK1.7 and running Clean and Build: no more warnings. :-)
From a blog post:
To use javac from JDK N to cross-compiler to an older platform version, the correct practice is to:
- Use the older -source setting.
- Set the bootclasspath to compile against the rt.jar (or equivalent) for the older platform.
If the second step is not taken, javac will dutifully use the old language rules combined with new libraries, which can result in class files that do not work on the older platform since references to non-existent methods can get included.