NetBeans
Build Apache NetBeans from source, clear the Recent Projects list and choose the JDK the IDE runs on.
2 min readUpdated
Apache NetBeans is an open-source IDE for Java and other languages, built with Apache Ant. This note builds it from the Git repository, and covers two settings that are not in the options dialog: the Recent Projects list and the JDK the IDE itself runs on.
Build and run from source
The build needs Git, Apache Ant and a JDK. Current NetBeans sources require JDK 21 or later.
-
Install the JDK and Ant, and point
JAVA_HOMEat the JDK (or leaveJAVA_HOMEandANT_HOMEunset). -
Clone the repository:
Terminal window git clone https://github.com/apache/netbeans.gitcd netbeans -
Build the default
releaseconfiguration. This compiles the IDE and assembles the NetBeans Platform:Terminal window ant buildPlain
antruns the default target,build-nozip, which builds the same IDE without packing the ZIP distribution. To build less, choose a smaller cluster configuration, for exampleant -Dcluster.config=basic buildfor mainly the Java features. -
Start the IDE you just built:
Terminal window ./nbbuild/netbeans/bin/netbeansant trymedoes a quick test run instead.
If a build fails:
- Check that
JAVA_HOMEpoints to a supported JDK. - Remove cached build output and start again. The README recommends
git clean -Xdf, which deletes every file ignored by Git;ant cleanis the lighter option. - The
nbbuilddirectory contains most of the build scripts and configuration, and the portable ZIP distribution after a successful build.
Remove projects from the Recent Projects list
The Start Page and File > Open Recent Project read their list from projectui.properties in the NetBeans user directory. On macOS the file is here:
~/Library/Application Support/NetBeans/<netbeans-version>/config/Preferences/org/netbeans/modules/projectui.propertiesClose NetBeans, then remove the entries of the projects you no longer want from the file, or delete the file to clear the list. Help > About shows the user directory on other systems.
Set the JDK NetBeans runs on
The JDK that runs the IDE is set by netbeans_jdkhome in netbeans.conf, in the etc directory of the installation. On macOS:
/Applications/Apache NetBeans.app/Contents/Resources/netbeans/etc/netbeans.confChange the line so that it points at your Java installation. Editing the file may need administrator rights. This example uses the Homebrew OpenJDK on an Intel Mac; on Apple silicon Homebrew lives in /opt/homebrew instead of /usr/local:
netbeans_jdkhome="/usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home"To try a JDK for one session without editing the file, start the launcher with --jdkhome:
netbeans --jdkhome /path/to/jdkThis JDK is also the default JDK for new projects. Projects can use other JDKs, added in Tools > Java Platforms.