1

When setting up Netbeans 12.2, one part of the installer lets you select the JavaSDK that you'll use as the Default. Is there any way to change this later on, like when a new version of the JavaSDK comes out?

Charlee
  • 9
  • 5
  • Does this answer your question? [Change JRE in NetBeans project](https://stackoverflow.com/questions/4128256/change-jre-in-netbeans-project) – dan1st Feb 11 '21 at 23:01
  • @dan1st - No, I'd like to change the default without having to first create the project. – Charlee Feb 11 '21 at 23:13
  • 1
    My fault. What about [this](https://stackoverflow.com/q/10146819/10871900) and [this](https://stackoverflow.com/q/2809366/10871900)? – dan1st Feb 11 '21 at 23:15
  • 1
    I just did this recently for my NB 12 on Windows 10. The installation directory was `C:\Program Files\NetBeans-12.2\netbeans`. From there, I went to `etc\netbeans.conf`. I edited this: `netbeans_jdkhome="C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot"`. So, yes, basically what the dan1st links say. (Semi-related: I always also add ` -J-Dfile.encoding=UTF-8` to the end of the `netbeans_default_options` list, for new installations, for better handling of UTF-8 output in the console.) – andrewjames Feb 12 '21 at 01:50
  • Yeah, I think you guys have gotten it. I did find a GUI selection under Tools > Options > Java and then you could change the platform, but I don't know if that changes the default (doesn't change the name). – Charlee Feb 12 '21 at 19:06
  • I just checked that GUI, and indeed you can select the Java Platform to be used for the various tools (e.g. Maven or the Java Scripting shell). But these tools, just like your projects no not necessarily have to be the same version that the IDE is running on. – Hiran Chaudhuri Feb 12 '21 at 19:20

1 Answers1

1

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.

Hiran Chaudhuri
  • 670
  • 3
  • 14
  • Everything else I could find pointed toward changing some sort of jdk_home for older versions, I think you're right here. I haven't had a chance to test yet, but if I remember to come back here I'll let you know! – Charlee Feb 12 '21 at 19:07
  • You're awesome @Hiran ! Yes, it looks like that worked! – Charlee Apr 01 '21 at 07:23