How to set a java compiler in Netbeans

孤街浪徒 提交于 2019-11-27 09:12:45
alain.janinm

Right click on your project --> Project Properties

Then in Sources set Source/Binary Format to JDK 7.

EDIT 1 :

There is a NetBeans issue:

Works fine in J2SE project, Web project specific problem. The problem is that fork="false" the JDK 7.0 params are passed to JDK 6.0 compiler. The executable requires fork="true".

On the line 293 of build-iml.xml the

<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}">

should become:

<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}">

EDIT 2 (if first tips don't work):

Try to run Netbeans IDE in JDK7.

Edit Netbeans conf file :

Linux

~/.netbeans/7.0/etc/app.conf

Mac Os X

/Applications/NetBeans/NetBeans\ 7.1.app/Contents/Resources/NetBeans/harness/etc/app.conf

Add the jdk7 path in the line jdkhome=.

Or

Launch netbeans using :

netbeans --jdkhome /Java7/Home/dir

whats_in_a_name

Update for NetBeans 8:

The file to edit is

/Applications/NetBeans/NetBeans\ 8.0.app/Contents/Resources/NetBeans/harness/etc/app.conf

I added the line

jdkhome="/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk"

and restarted NetBeans, it accepted JDK 1.7 U67 as its compilation platform.

This worked for me You can try this.

I was using Netbeans 8.2 and the jdk it was using was 1.8 and i wanted to compile the project in lower java version of 1.7. Right click on your project and go to the properties tab [properties tab options][1]

click on libararies.

Then click on manage libraries. [Manage libraries][2]

after that Add platform and add ur javapath and close [Adding java platform ][3]

Then you can build your project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!