How to build NetBeans from sources (updated)
By Jonathan Lermitage on Thursday 21 February 2013, 18:06 - NetBeans IDE - Permalink
I'll try to explain how to retrieve the NetBeans IDE sources from the official Mercurial repository, and build it in two different ways : via an existing IDE and the command line (and Ant).
Summary :
- checkout the NetBeans 7.3.0 FCS sources from Mercurial repository.
- build NetBeans with an existing IDE.
- alternative : build from the command line.
- how to use JDK7 instead of JDK6.
Version history :
- v3, Thursday 21 February 2013 : update for NetBeans 7.3.0
- v2, Tuesday 15 January 2013 : update for NetBeans 7.2.1 and added a note about JDK7 usage
- v1, Friday 20 April 2012 : original version, for NetBeans 7.1.1
Step 1 : checkout the NetBeans 7.3.0 FCS sources from Mercurial repository
- download and install a Mercurial client. You can find command-line and GUI programs at http://mercurial.selenic.com.
- go the the directory that will contain the NetBeans sources and check out the
http://hg.netbeans.org/releases/
URL.
You can do it with the command-line :hg clone http://hg.netbeans.org/releases/. It will download NetBeans sources and the Mercurial change-set : expect a few GB of free space. - now, we have all NetBeans releases sources. We need to switch to NetBeans 7.3.0 sources only, not the latest version (something like NetBeans DEV).
- go into the
releases
directory and launch the Mercurial command :hg checkout release73_fcs.
TIP : how do I know the release73_fcs
tag ? Go to http://hg.netbeans.org/releases/ and look at the tag
section : you have a list of the latest tags. release73_fcs
means NetBeans version 7.3.0, First Customer Shipment (FCS)
.
Step 2 : build NetBeans with an existing IDE
You can now start your existing NetBeans IDE and load the nbbuild
project. The displayed project name will be NetBeans Build System
:

Nota : the error badge is normal. It will disappear when building the IDE.
Now, you only have to do two actions, via the contextual menu (right-click on the project) :
- launch the
Build
action. It will be fast and won't generate any error. - launch the
Build IDE (no ZIP file)
action. It will take a long time, depending on your computer performances.
If you encounter any build error, you can try theClean and Build
action, the retryBuild IDE (no ZIP file)
.

You can now go to the releases/nbbuild/netbeans/
directory : in contains the built IDE. You'll find the Netbeans executables for Windows and Linux in the bin
subdirectory. Don't forget to customize the etc/netbeans.conf
file to set a JDK location, etc.
Alternative : build from the command line (added Saturday 20 October)
If you don't want to build the IDE thanks to an existing NetBeans version, you can simply use an Ant script.
If you are not familiar with Ant and/or the command line interface of your operating system :
- download the latest Apache Ant binary distribution from http://ant.apache.org/bindownload.cgi. Unzip it where you want.
- go to the directory where you have checked out the NetBeans sources and open the command line prompt (for MS Windows users, this is the CMD program). You can write a BAT/SH script too (the following instructions are for Windows only, but they are easy to convert to Unix shells).
- type and execute
set "JAVA_HOME=C:\Java\jdk1.6.0"(whereC:\java\jdk1.6.0
is your JDK path). - type and execute
set "ANT_HOME=C:\Java\apache-ant"(whereC:\java\apache-ant
is the directory where you have unzipped the Ant software). - type and execute
set "ANT_OPTS=-Xmx512m -XX:MaxPermSize=256m"to allow Ant script to use more memory (increase these values if you encounter an OutOfMemoryException error when you build the IDE). - type and execute
set "PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin": it will add the Ant and JDK bin folders to your path, so you'll can call Ant and JDK executables easily.
Now, you can simply build your IDE :
- type and execute
ant(if you encounter an error message about your Java version, run and executeant -Dpermit.jdk6.builds=true -Dnbjdk.home=C:/Java/jdk1.6.0).
Enjoy ;)
How to use JDK7 instead of JDK6 (added Tuesday 15 January)
NetBeans 7.x is designed to be built against JDK6, but you can bypass this constraint.
- If you want to use JDK7 to build the IDE, simply replace
ant -Dpermit.jdk6.builds=true -Dnbjdk.home=C:/Java/jdk1.6.0byant -Dpermit.jdk7.builds=true -Dnbjdk.home=C:/Java/jdk1.7.0(adjust the JDK7's path if necessary). - To use JDK7 to build NetBeans modules (by opening and building projects from the IDE), simply create a file called
user.build.properties
into thereleases/nbbuild/
directory. Edit this file to put this content:permit.jdk7.builds=truenbjdk.home=C:/Java/jdk1.7.0
Without theses properties, compilation of NetBeans modules will fail with an error message that indicates you have to use JDK6.
Comments
This is an excellent blog, congratulations
Do you know the main differences between
hg.netbeans.org/main-releases and hg.netbeans.org/main?
Hi,
you can find descriptions and status of repositories here: http://wiki.netbeans.org/List_Of_Re...
The "releases" repo is probably the best way to work with releases. The "main" repo may contain more stuff (given to its description and changeset).
In practice, there is no relevant difference between the "releases" and "main" repositories if you want to build or study stable releases : you'll find the useful tags in both repo.
Thanks for this very useful post, I have searched a lot for how to build NetBeans from sources, now it seems I have found the solution. Later in the evening I will try it.