Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress bootstrap class path warning when targetting Java 6 and using JDK 7 compiler

Tags:

java

javac

Our open source app targets the Java 6 platform so we compile with the -source 1.6 and -target 1.6 options but when using JDK 7, we get this warning message, e.g.

For example: $ javac -source 1.6 -target 1.6 test.java

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

We can resolve the problem by using the -bootclasspath for our machines, but we distribute our app as a source tarball/zip and our users build it on their machines.

Additionally, we DO NOT want to require user to download JDK6 just so they don't get this warning so the -bootclasspath option is not a good solution.

Of course we verify that we use only JDK 6 APIs, by using and testing JDK 6. So we would just like to suppress this warning when using JDK 7 to compile our source code.

I have scan through the javac options but cannot find out how to suppress this warning. http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html

Any ideas on how to do suppress JDK 7's bootstrap class path warning when targeting Java 6?

For now we just tell our users to ignore this but ideally, we don't want any warnings print at all.

like image 216
Neon Avatar asked May 31 '13 13:05

Neon


1 Answers

The warning can be disabled with a new JDK 7 suboption within the -Xlint family, -Xlint:-options. e.g.

$ javac -source 1.6 -target 1.6 -Xlint:-options test.java

sources: https://blogs.oracle.com/darcy/entry/bootclasspath_older_source and http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#xlintwarnings

Warnings That Can Be Enabled or Disabled with -Xlint Option

Enable warning name with the option -Xlint:name, where name is one of the following warning names. Similarly, you can disable warning name with the option -Xlint:-name: ...

options Warn about issues relating to the use of command line options. See Cross-Compilation Example for an example of this kind of warning.

like image 116
Neon Avatar answered Oct 20 '22 11:10

Neon