bootstrap class path not set in conjunction with -source 1.6
Asked Answered
A

2

11

I am upgrading my application from java 1.6 to 1.7. When I try to build using Maven 3.2.1, my build fails with below error msg:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project my-app5: Compilation failure: Compilation failure:
[ERROR] could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.6  

I am using java 1.7 hotspot and previously I was using 1.6 jrockit. My application is multi module and few modules compile and build as usual, this module failed.

I have set java home properly and mvn --version shows below output:

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T23:07:52+05:30)
Maven home: C:\Users\me\Maven3\apache-maven-3.2.1-bin\apache-maven-3.2.1\bin\..
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\jdk17051\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"  

Am I missing anything?

Aneroidograph answered 8/5, 2014 at 13:56 Comment(3)
Trying the result from here: Maven compile errorAneroidograph
Added <source>1.7</source> <target>1.7</target> to my compiler plugin config. Didnt help...still getting same error msg and build is failingAneroidograph
possible duplicate of warning: [options] bootstrap class path not set in conjunction with -source 1.5Chronological
A
7

I solved it using below configuration in my compiler plugin:

<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>  

This will use the JDK which you have defined in your JAVA_HOME environment property.

Aneroidograph answered 9/5, 2014 at 12:31 Comment(0)
S
6

Quote from this post:

Java 5.0 and 6 used to have poor support for compiling classes to target older versions of Java. It always supported the previous version, but often no more. Even if you could compile for previous version, you had to be careful not to use functionality which did exist in the previous versions.

You should either include -Xbootclasspath when using javac:

javac -Xbootclasspath:/path/to/jdk6/rt.jar -target 1.6 -source 1.6 Main.java

or compile using -target 1.7 (or higher of course):

javac -target 1.7 -source 1.7 Main.java

or use javac of jdk 6:

/path/to/jdk6/bin/javac Main.java
Split answered 9/12, 2014 at 19:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.