bootstrap class path not set

I understand that I need to set the bootstrap class path but I am not sure I understand how.

In Netbeans 8.0.2, go to:

Run > Set Project Configuration > Customise...

In the Categories window, go to:

Build > Compiling

The bottom field is "Additional Compiler Options" to which you can add:

-bootclasspath /your/path/to/lower/java/version/lib/rt.jar

Was having the same Warning compiling on console on macOS. Here the compiler-option to be added is

-bootclasspath /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar

Note that on macOS, for Java versions <= 1.6 (those released by Apple) the rt.jar is called classes.jar


In my case maven was using the another java version and I fixed it by changing the required java version in maven.


You are doing cross compiling. You are using a JDK 7 compiler to compile classes for JDK 6. This is okay but to avoid problems the compiler wants to get its hands on JDK 6 rt.jar. The reasoning behind that is that you actually might generate classes that don't work with JDK 6 because you might be using the old language rules (in this case 1.6) but the brand new bootstrap classes. Some methods might not be present in the older JDK for example. So you get your compilation done but once you run the program it might blow up with a MethodNotFoundException.

Couple of solutions, you can just pick one

  • Specify rt.jar from JDK 6. Why not use the older compiler than even?
  • Use JDK 6 compiler (it has rt.jar included). Why even use 7 if no 7 features are needed.
  • Ignore the warning and have good test coverage to make sure you don't use Java 7 features
    • I don't know about NetBeans but in Eclipse you can also say that you are compiling against JDK 6 so it won't actually compile if you use Java 7 features.
  • Change business needs and compile for Java 7.