How can I set the JDK NetBeans runs on?
Thanks to Kasun Gajasinghe's tip, I found the solution in the "suggested" link. Update the following file (replace 7.x with your NetBeans version):
C:\Program Files\NetBeans 7.x\etc\netbeans.conf
Change the following line to point it where your Java installation is:
netbeans_jdkhome="C:\Program Files\Java\jdk1.7xxxxx"
You may need administrator privileges to edit netbeans.conf
.
Changing java platform on which netbeans runs
You can change the JDK for Netbeans by modifying the config file:
- Open
netbeans.conf
file available underetc
folder inside the NetBeans installation. - Modify the
netbeans_jdkhome
variable to point to new JDK path, and then - Restart your Netbeans.
How can I set the default Java platform in NetBeans 8.2?
For now, it appears there isn't any way to override it. Here is NetBeans Help about the Java Platform Manager:
Use to register different versions of the Java Development Kit (JDK) and other Java tools that your programs depend on. The dialog box lists all of your registered JDKs in the left pane and lists the JDK that the IDE is running on as the Default Platform.
So I'll have to change platform for each project, because NetBeans 8.2 can not run with JDK 1.7 (so I can't set it as the default platform).
There is a recent plugin that allows to right-click Maven projects to set the JDK (still cannot set it by default).
Where can I set the JRE/JDK which is used to run Netbeans besides the command line?
Try setting netbeans_jdkhome in {NetBeans directory}/etc/netbeans.conf.
# Default location of JDK, can be overridden by using --jdkhome :
netbeans_jdkhome="..." # (omitted path, as I have Java in a non-standard location)
How can I change the default SDK for Netbeans 12.2?
It is possible to change the platform later.
You need to distinguish between two platforms:
- the one that netbeans is running on (yes, it is a Java based IDE)
- the one that will be used to compile your project
If you want to change the Java version for the IDE, check the configuration file in the netbeans/etc folder (on my windows machine it is C:\Program Files\NetBeans-12.2\netbeans\etc\netbeans.conf
. In line 76 I see the variable netbeans_jdkhome
.
If you installed another JDK on your machine and want to choose that for projects, inside Netbeans go to Tools/Java Platforms. Add your new installation. Then when you go to some project's properties, look at the Build/compile settings. Choose your new java platform, and it will be used for your project.
How to set a java compiler in Netbeans
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" ;as opposed to ${javac.fork}
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
Installing Netbeans 8.2 on MacOS Big Sur no JDK found
I had the same problem.
I have not needed to restart the computer.
I have simply changed the line:
netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"
in the file netbeans.conf, from the directory:
/Applications/NetBeans/NetBeans\ 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf
and this has worked for me
Related Topics
How to Get Absolute Path to File in /Resources Folder of Your Project
Java:Parse Java Source Code, Extract Methods
Java Recursive Fibonacci Sequence
Why Java.Util.Optional Is Not Serializable, How to Serialize the Object with Such Fields
Converting Secret Key into a String and Vice Versa
How to Scale Threads According to CPU Cores
Java Synchronized Block for .Class
How to Make a Java Class That Implements One Interface with Two Generic Types
What Does It Mean: the Serializable Class Does Not Declare a Static Final Serialversionuid Field
Shared Memory Between Two Jvms
Adding Up Bigdecimals Using Streams
Is There a Java Utility to Do a Deep Comparison of Two Objects
A Regex to Match a Substring That Isn't Followed by a Certain Other Substring
How to Add a New Line of Text to an Existing File in Java
How to Disable Jsessionid in Tomcat Servlet
How to Specify a Byte Literal in Java