Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

warning: [options] bootstrap class path not set in conjunction with -source 1.5

Tags:

java

I get the warning message at Build time!

warning: [options] bootstrap class path not set in conjunction with -source 1.5

How can I fix it?

like image 348
Sam Avatar asked Oct 19 '11 04:10

Sam


2 Answers

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.

like image 81
Eduard Wirch Avatar answered Sep 29 '22 14:09

Eduard Wirch


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.