如何在Netbeans中设置java编译器
我正在进行Java7开发,我已经将JDK7添加到Java平台中,并在项目属性中选择了它 但在编译时,我会收到如下消息:如何在Netbeans中设置java编译器,netbeans,javac,java-7,Netbeans,Javac,Java 7,我正在进行Java7开发,我已经将JDK7添加到Java平台中,并在项目属性中选择了它 但在编译时,我会收到如下消息: warning: java/lang/Boolean.class(java/lang:Boolean.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upg
warning: java/lang/Boolean.class(java/lang:Boolean.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
及
据我所知,Netbeans正在使用JavaC1.6。我怎样才能换到1.7
编辑:
我正在编写一个NetBeans平台应用程序,在我设置的主要应用程序属性中:Java平台=JDK 1.7。在模块的一个属性中,我设置了源代码级别=1.7 编辑2
- Mac OS10.7.3
- NetBeans IDE7.1(构建201112071828)
- openjdk版本“1.7.0-internal”
- OpenJDK运行时环境(build 1.7.0-internal-uko_2012_02_15_11_51-b00)
- OpenJDK64位服务器虚拟机(构建23.0-b15,混合模式)
common.xml(这里第二行是206)
右键单击项目-->项目属性
然后在Sources
中将Source/Binary格式设置为JDK 7
编辑1:
有一个:
在J2SE项目、Web项目的具体问题中工作良好。
问题是,fork=“false”将JDK 7.0参数传递给JDK 6.0
编译器。可执行文件需要fork=“true”
在build-iml.xml的第293行
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}"
encoding="${source.encoding}" excludes="@{excludes}"
executable="${platform.javac}" fork="${javac.fork}" includeantruntime="false"
includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}"
target="${javac.target}" tempdir="${java.io.tmpdir}">
应成为:
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}"
encoding="${source.encoding}" excludes="@{excludes}"
executable="${platform.javac}" fork="yes" includeantruntime="false"
includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}"
target="${javac.target}" tempdir="${java.io.tmpdir}">
编辑2(如果第一个提示无效):
尝试在JDK7中运行Netbeans IDE
编辑Netbeans配置文件:
Linux
~/.netbeans/7.0/etc/app.conf
Mac Os X
/Applications/NetBeans/NetBeans\7.1.app/Contents/Resources/NetBeans/harness/etc/app.conf
在jdkhome=
行中添加jdk7路径
或
使用以下命令启动netbeans:
netbeans——jdkhome/Java7/Home/dir
NetBeans 8的更新:
要编辑的文件是
/应用程序/NetBeans/NetBeans\
8.0.app/Contents/Resources/NetBeans/harness/etc/app.conf
我加了一行
jdkhome="/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk"
重新启动NetBeans后,它接受jdk1.7u67作为编译平台。这对我很有效,你可以试试
我使用的是Netbeans 8.2,它使用的jdk是1.8,我想用1.7的较低java版本编译这个项目。
右键单击项目并转到“属性”选项卡
[物业标签选项][1]
点击图书馆
然后单击管理库。
[管理图书馆][2]
然后添加平台并添加ur javapath并关闭
[加入java平台][3]
然后您可以构建您的项目。我正在编写一个NetBeans平台应用程序,并在我设置的主要应用程序属性中:Java Platform=JDK 1.7。在模块的一个属性中,我将源代码级别设置为1.7。所以问题不在项目设置中检查此链接可能解决方案也在那里是的,但问题在Web应用程序中,我正在使用Java SE。在我的应用程序中,我的build.xml
中没有javac任务。错误并不是指向我的ant构建脚本,而是指向一些利用xmlsOk的工具,您能否在这个问题上分享一下XML行suite.XML:184
和common.XML:206
?编译器说错误在这里。你能给出你的netbeans版本和操作系统吗?编辑netbeans配置文件,我的位于:~/.netbeans/7.0/etc/app.conf
。取消注释jdkhome=
行并设置jdk7。
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}"
encoding="${source.encoding}" excludes="@{excludes}"
executable="${platform.javac}" fork="${javac.fork}" includeantruntime="false"
includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}"
target="${javac.target}" tempdir="${java.io.tmpdir}">
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}"
encoding="${source.encoding}" excludes="@{excludes}"
executable="${platform.javac}" fork="yes" includeantruntime="false"
includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}"
target="${javac.target}" tempdir="${java.io.tmpdir}">
jdkhome="/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk"