Java/Maven/Tomcat:引导类路径未与 -source 1.6 一起设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18475808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java/Maven/Tomcat: bootstrap class path not set in conjunction with -source 1.6
提问by Mr Mikkél
So, I have more than one version of Java installed on the system (1.7 and 1.6). I need to use 1.6, so, being on Ubuntu, I did an update-alternatives --config java and changed it to the 1.6. Now java -version tells me I'm using 1.6.
因此,我在系统上安装了不止一个版本的 Java(1.7 和 1.6)。我需要使用 1.6,因此,在 Ubuntu 上,我做了一个 update-alternatives --config java 并将其更改为 1.6。现在 java -version 告诉我我使用的是 1.6。
So, I'm trying to build using Maven. If I do a mvn clean install, I end up with the following error:
所以,我正在尝试使用 Maven 进行构建。如果我进行 mvn 全新安装,最终会出现以下错误:
[ERROR] bootstrap class path not set in conjunction with -source 1.6
/path/to/SomeResultSetStub.java:[32,7] error: SomeResultSetStub is not abstract and does not override abstract method <T>getObject(String,Class<T>) in ResultSet
I did some looking for that error, and it seems like I need to set some kind of BootClassPath somewhere, but I can't seem to find very explicit instructions for doing so.
我做了一些寻找该错误的工作,似乎我需要在某处设置某种 BootClassPath,但我似乎找不到这样做的非常明确的说明。
Can anyone guide me through resolving the error?
谁能指导我解决错误?
回答by R. Oosterholt
When using javac in conjunction with -source you need to specify the bootstrap classpath to make sure no runtime errors occur when running your compiled code on a 1.6 jvm...
将 javac 与 -source 结合使用时,您需要指定引导类路径以确保在 1.6 jvm 上运行编译代码时不会发生运行时错误...
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
$ javac -target 1.7 -source 1.7 Main.java
$ javac -target 1.6 -source 1.6 Main.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
$ javac -Xbootclasspath:/usr/java/jdk1.6.0_29/jre/lib/rt.jar -target 1.6 -source 1.6 Main.java
$ javac -Xbootclasspath:/usr/java/jdk1.5.0_22/jre/lib/rt.jar -target 1.5 -source 1.5 Main.java
$ javac -Xbootclasspath:/usr/java/jdk1.4.0_30/jre/lib/rt.jar -target 1.4 -source 1.4 Main.java
$ javac -Xbootclasspath:/usr/java/jdk1.3.1_29/jre/lib/rt.jar -target 1.3 -source 1.3 Main.java
$ javac -Xbootclasspath:/usr/java/jdk1.2.2_017/jre/lib/rt.jar -target 1.2 -source 1.2 Main.java
$ javac -Xbootclasspath:/usr/java/jdk1.1.8_16/jre/lib/rt.jar -target 1.1 -source 1.2 Main.java
$ javac -Xbootclasspath:/usr/java/jdk1.1.8_16/jre/lib/rt.jar -target 1.1 -source 1.1 Main.java
javac: invalid source release: 1.1
Usage: javac
use -help for a list of possible options
$ javac -Xbootclasspath:/usr/java/jdk1.1.8_16/jre/lib/rt.jar -target 1.0 -source 1.0 Main.java
javac: invalid target release: 1.0
Usage: javac
use -help for a list of possible options
See http://vanillajava.blogspot.nl/2012/02/using-java-7-to-target-much-older-jvms.htmlfor more information.
有关更多信息,请参阅http://vanillajava.blogspot.nl/2012/02/using-java-7-to-target-much-older-jvms.html。
回答by hoijui
The "bootstrap class path" error may only appear, if you are using a JDK other then version 6. as you said you want to use JDK 6, and you seem to use an other version, you should first change that. Apart from that though, your question would be a duplicate of: warning: [options] bootstrap class path not set in conjunction with -source 1.5
“引导程序类路径”错误可能只会出现,如果您使用的是 6 版以外的 JDK。正如您所说,您想使用 JDK 6,而您似乎使用的是其他版本,您应该首先更改它。除此之外,您的问题将与以下内容重复: 警告:[options] bootstrap class path not set with -source 1.5