bootstrap类路径未设置 [英] bootstrap class path not set

查看:534
本文介绍了bootstrap类路径未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我得到 - 警告:[options] bootstrap类路径未与-source 1.6一起设置

我要问3个问题。我理解我需要设置引导类路径,但我不知道我是如何理解的。一个快速的google刚刚发送到从Oracle页面引用的页面,但我读的Oracle页面,并没有觉得我理解它特别好。

And I am about to ask 3 questions about it. I understand that I need to set the bootstrap class path but I am not sure I understand how. A quick google just sent me to pages that quoted from the Oracle page, but I read the Oracle page and didn't feel that I understood it particularly well.

我是目前在Netbeans上运行这个代码,所以我要做的就是点击播放按钮来编译和运行。是否有一个属性,指示这将如何编译,以便我可以添加在引导类路径?

I am currently running this code on Netbeans, so all I have to do is hit the play button for it to compile and run. Is there a property that dictates how this will compile so that I may add in the bootstrap class path?

此外,对于即将到来的可能性,我将它关闭只运行在Netbeans上,并从命令行运行它是什么是正确的方法来编译与引导类路径那里?他们说 $ javac -source 6 HelloWorld.java 但只是说明 -source 1.6 真的是解决方案吗?

Also, for the coming eventuality that I will take it off running only on Netbeans and run it from the commandline, what is the correct way to compile with the bootstrap class path there? They say $ javac -source 6 HelloWorld.java but would just stating -source 1.6 really be the solution?

也许是一个更大的问题,如何避免这种类型的警告在未来?如果我甚至理解一点,我引用一个老的java源,因此旧的方法。我不知道如何或什么时候发生。

Perhaps an even greater question in, how do I avoid this type of warning in the future? If I understand even a little bit, I am referencing an old java source and therefore older methods. I am not sure how or when that happened.

推荐答案

您正在进行交叉编译。你正在使用JDK 7编译器来编译JDK 6的类。这是可以的,但为了避免编译器希望得到它的JDK 6 rt.jar 的问题。其背后的原因是,实际上可能生成不能使用JDK 6的类,因为您可能使用旧语言规则(在这种情况下为1.6),但是全新的引导类。例如,某些方法可能不存在于旧版JDK中。所以你得到你的编译完成,但一旦你运行程序,它可能会爆炸与 MethodNotFoundException

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


  • 从JDK 6指定 rt.jar 为什么不使用比甚至更旧的编译器?

  • 使用JDK 6编译器(包含 rt.jar )。如果不需要7个功能,为什么还要使用7.

  • 忽略警告并具有良好的测试覆盖率,以确保不使用Java 7功能

    • 我不知道NetBeans,但在Eclipse中,你也可以说,你正在编译JDK 6,所以如果你使用Java 7的功能,它实际上不会编译。


      • 更改业务需求并针对Java 7进行编译。

      • 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.

        这篇关于bootstrap类路径未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆