Search code examples
javamavenjava-7building

Bootstrap classpath not set


I just upgraded my java to 1.7.0_60. I'm using maven to build my components. When I try to run mvn test on a component, I get this error message-

[INFO] Compilation failure could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.5

I thought it could have something to do with tools.jar and explicitly mentioned them in my pom.xml

    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>C:\Program Files\Java\jdk1.7.0_60\lib\tools.jar</systemPath>
    </dependency>

But I'm still getting the same issue. In order to get rid of this what and how should I do it?


Solution

  • You are compiling for Java source version 1.5, but you are using JDK 7 to compile. This means that the compiler uses the Java 7 class library to link you code, which may result in problems at runtime.

    For example, if your code uses the Long.compare(long, long) method, the compilation will succeed, even if you set the target to 1.5, because at compile time the compiler checks the Long class (from the Java 7 class library) and sees that yes, indeed, a Long.compare(long, long) method does exist. However, when you try run this code on Java 1.5, it will fail, because Java 1.5 does not have a Long.compare(long, long) method.

    Basically, the compiler is warning you that you are claiming that this code is Java 1.5 compliant, but that the Java class library you are compiling against may contain methods that do not actually exist in Java 1.5.