Build the latest NetBeans yourself

This blog post describes how to clone and build NetBeans from the Hg repository. It also contains some notes that I received from my friends who followed my original instructions. Official (and maybe less detailed) info can be found here: http://wiki.netbeans.org/WorkingWithNetBeansSource

Any comments are very welcome!

What do I need to start?

  • Approximatelly 3+ hours of your time (you don't need to work for 3 hours, but some time is needed for the download and the build)
  • Mercurial VCS: Distributed version control system, used for development in NetBeans team (and in Mozilla, for example).
    • Note for non-english speaker: Hg = Mercurial (chemistry: Hg → Mercury)...
  • JDK5: NetBeans cannot be (easily) built with JDK6. The build is somehow possible, but currently it is not very simple, even for more experienced user... The main reason for using JDK5 is that NetBeans must be runnable with JDK5 or newer - by using 1.5.0 you will ensure that you don't use APIs and features available only in JDK 6 or newer.
  • Ant: It is - simply said - "make for Java", a build tool using XML files to specify build targets, ...


How do I install Mercurial, Ant and JDK5?

  • Ubuntu linux: sudo apt-get install ant ant-optional sun-java5-jdk mercurial
  • Windows:
    1. Download and install (follow the guidelines on the product's pages) binaries from these pages:
      • Mercurial (note: use this one, do NOT use TortoiseHg!)
      • JDK 5.0 Update 17
      • Ant
      • Test if you have properly set PATH variables: type hg and ant in the command line, you should get a response from the application (not just an "Application not found" message). Set the PATH variable to the folders of appropriate binaries if needed...
      • Please note that if you have newer version of JDK installed together with the older version, and your Ant is throwing an error message, you can add an environment variable JAVA_HOME pointing to the previous version of JDK.

How to clone NetBeans repository?

  • Both operating systems: If you have proper Hg installation, you should be able to call: hg clone http://hg.netbeans.org/main-golden
    • Note: This will clone the main-golden repository (this is the one that dailies of NB come from) in the directory where you called "hg clone". Navigate to desired folder first!
    • Note: be patient, clone can take more than 2 hours (depends on the speed of connection)
    • Note: Hg is not very chatty - you can improve it little by -v (verbose) switch, but it is still more quiet then feels convenient...

How to set up the build environment?

  • Before you attempt to build NetBeans from the sources for the first time, you must do following:
    1. Create files
      • {$NB_REPO_CLONE}/main-golden/nbbuild/user.build.properties
      • {$HOME}/.nbbuild.properties
    2. Place following content (desctiption/explanation is inline) to the files
      • nbjdk.home=/path/to/jdk15/folder
        • Note: Windows users must use "\\\\" ("escaped backslash") as a path separator!
      • build.compiler=extJavac
      • javac.compilerargs=-J-Xmx512m
        • Note: If this option was ignored, setting environmental variable ANT_OPS (to ANT_OPTS="-Xmx512m") should help

How to build NetBeans for the first time?

  • Follow previous steps!!!
  • Start terminal
  • Navigate to the {$NB_REPO_CLONE}/main-golden and type: ant
  • Wait - full "clean" build takes quite long (expect 30-60 minutes).


My build was sucessfull. How to run NetBeans now?

  • There are 2 possibilities:
    1. Stay in {$NB_REPO_CLONE}/main-golden and type ant tryme, or ...
    2. Navigate to {$NB_REPO_CLONE}/main-golden/nbbuild/netbeans/bin folder and run netbeans from there


I built NetBeans X months ago and I would like to build a version with updated sources - how do I do it?

  • Start terminal, navigate to {$NB_REPO_CLONE}/main-golden folder
  • If you made some local changes, commit them: hg ci -m "my commit message"
    • Note: you mustn't have uncommitted changes before performing the next step
    • Note: committing will change only your local repository - see how Hg works, you are not allowed to mess with the official NetBeans, so don't worry you break something by committing
  • Fetch the changes: hg fetch
    • Note: the fetch command is a convenient one-command-only way of performing pull (download remote changes), update (update local copy) and merge (merge changes)
    • Note: if fetch does not work for you, use "hg pull -u; hg merge"
  • Build updated version of sources using ant (the same as the first build)
Comments:

Post a Comment:
Comments are closed for this entry.
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today