Home > misc, документация, наука > How to build OpenJDK projects from NetBeans

How to build OpenJDK projects from NetBeans

This instruction specifies how you can build following OpenJDK projects using NetBeans IDE:

  • Hotspot
  • CORBA
  • JAXP
  • JAXWS
  • Langtools
  • JDK (J2SE)
  • Swing
  • JMX
  • JConsole

To start, you have to create VM, get OpenJDK source code, install a set of packages, and build OpenJDK from command line, as it described in Adopt OpenJDK VM Build.

  • How to build Hotspot

For Hotspot there is no NetBeans project. To build Hotspot you can run “make all” command from a Terminal

cd ~/sources/jdk8_tl/hotspot/make ;
make all &> hotspotBuild.log ;

or use Hacking Hotspot in Eclipse instruction.

  • How to build CORBA

For CORBA project there is no NetBeans project. To build it you can run

vi ~/.bachrc

from a Terminal and append:

export ALT_JDK_IMPORT_PATH=/usr/lib/jvm/java-7-openjdk-amd64

Then execute

source ~/.bashrc ;
cd ~/sources/jdk8_tl/corba/make ;
make all ;

The built files that will be imported into the jdk build will be in the “~/sources/jdk8_tl/corba/dist” directory.

  • How to build JAXP

To build JAXP project from NetBeans you should:
1. Run NetBeans. Open jaxp project using File–>Open Project. It is located here: ~/sources/jdk8_tl/

2. (Optional) Create a file with name “build.properties” at the
~/sources/jdk8_tl/jaxp/nbproject/private
with following content:

#PATH to JDK7
bootstrap.jdk=/usr/lib/jvm/java-7-openjdk-amd64

3. In jaxp NetBeans project right click on “build.xml” file, then select “Run Target” and click on “dist” target.
The built files that will be imported into the jdk build will be in the “~/sources/jdk8_tl/jaxp/dist” directory.

  • How to build JAXWS

To build JAXWS project from NetBeans you should:
1. Run NetBeans. Open jaxws project using File–>Open Project. It is located here: ~/sources/jdk8_tl/

2.  (Optional) Create a file with name “build.properties” at the
~/sources/jdk8_tl/jaxws/nbproject/private
with following content:

#PATH to JDK7
bootstrap.jdk=/usr/lib/jvm/java-7-openjdk-amd64

3. In jaxws NetBeans project right click on “build.xml” file, then select “Run Target” and click on “dist” target.
The built files that will be imported into the jdk build will be in the “~/sources/jdk8_tl/jaxws/dist” directory.

  • How to build Langtools

To build Langtools project from NetBeans you should:
1. Run NetBeans. Open langtools project using File–>Open Project. It is located here: ~/sources/jdk8_tl/langtools/make/netbeans

2. In langtools NetBeans project open “Build files” folder and then “build.properties” file. In this file uncomment line #32 and set

boot.java.home =/usr/lib/jvm/java-7-openjdk-amd64

3. In langtools NetBeans project right click on “build.xml” file, then select “Run Target” and click on “build” target.
The built files that will be imported into the jdk build will be in the “~/sources/jdk8_tl/langtools/dist” directory.

  • How to build JDK (J2SE)

(!!!) To build this project you should have Hotspot, JAXP, JAXWS, Langtools and CORBA builds.

To build JDK (J2SE) project from NetBeans you should:
1. Run NetBeans. Open j2se project using File–>Open Project. It is located here: ~/sources/jdk8_tl/jdk/make/netbeans/

2. Create a file with name “build.properties” at the
~/sources/jdk8_tl/jdk/make/netbeans/j2se/nbproject/private
with following content:

bootstrap.jdk=/usr/lib/jvm/java-7-openjdk-amd64
make.options=\
ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64 \
ALT_LANGTOOLS_DIST=~/sources/jdk8_tl/langtools/dist \
ALT_CORBA_DIST=~/sources/jdk8_tl/corba/dist \
ALT_JAXP_DIST=~/sources/jdk8_tl/jaxp/dist/ \
ALT_JAXWS_DIST=~/sources/jdk8_tl/jaxws/dist/ \
ALT_HOTSPOT_IMPORT_PATH=~/sources/jdk8_tl/hotspot/build/linux/export-linux-amd64 \
OPENJDK=true

3. In jdk (j2se) NetBeans project right click on “build.xml” file, then select “Run Target” and click on “build” target.

4. Wait near one or two hours

  • How to build Swing

(!!!) To build this project you should have JDK8 build. The following sentence from “Working on OpenJDK using NetBeans” README file is not correct:
“This ant-based project does *not* require that you build the jdk project first, provided that you use a pre-built version of JDK 7.”
JDK7 is not enough, because this project uses new classes and methods from jdk (j2se) 1.8.

To build Swing from NetBeans you should:
1. Run NetBeans. Open Swing project using File–>Open Project. It is located here: ~/sources/jdk8_tl/jdk/make/netbeans/

2. Create a file with name “build.properties” at the
~/sources/jdk8_tl/jdk/make/netbeans/swing/nbproject/private
with following content:

#Here you have to provide PATH to JDK8
bootstrap.jdk=/home/openjdk/sources/jdk8_tl/build/linux-amd64_backup/j2sdk-image

3. Run the Build of Swing project

4. Wait for 10 min – 1 hour (it depends on performance of your computer)

  • How to build JMX

(!!!) To build this project you should have JDK8 build. The following sentence from “Working on OpenJDK using NetBeans” README file is not correct:
“This ant-based project does *not* require that you build the jdk project first, provided that you use a pre-built version of JDK 7.”
JDK7 is not enough, because this project uses new classes and methods from jdk (j2se) 1.8.

To build JMX from NetBeans you should:
1. Run NetBeans. Open JMX project using File–>Open Project. It is located here: ~/sources/jdk8_tl/jdk/make/netbeans/

2. Create a file with name “build.properties”  at the
~/sources/jdk8_tl/jdk/make/netbeans/jmx/nbproject/private
with following content:

#PATH to JDK8
bootstrap.jdk=/home/openjdk/sources/jdk8_tl/build/linux-amd64_backup/j2sdk-image

3. Run the Build of JMX project

4. Wait for 10 min – 1 hour (it depends on performance of your computer)

  • How to build JConsole

(!!!) To build this project you should have JDK8 build. The following sentence from “Working on OpenJDK using NetBeans” README file is not correct:
“This ant-based project does *not* require that you build the jdk project first, provided that you use a pre-built version of JDK 7.”
JDK7 is not enough, because this project uses new classes and methods from jdk (j2se) 1.8.

To build JConsole from NetBeans you should:
1. Run NetBeans. Open JConsole project using File–>Open Project. It is located here: ~/sources/jdk8_tl/jdk/make/netbeans/

2. Create a file with name “build.properties” at the
~/sources/jdk8_tl/jdk/make/netbeans/jconsole/nbproject/private
with following content:

#PATH to JDK8
bootstrap.jdk=/home/openjdk/sources/jdk8_tl/build/linux-amd64_backup/j2sdk-image

3. Open file
~/sources/jdk8_tl/jdk/make/netbeans/common/shared.xml
and change values of java source and target to “1.7″ in lines #130 and #132.
Otherwise you will get following errors during the build phase:
“error: multi-catch statement is not supported in -source 1.5″

4. Run the Build of JConsole project

5. Wait for 10 min – 1 hour (it depends on performance of your computer)

6. Open file
~/sources/jdk8_tl/jdk/make/netbeans/common/shared.xml
and return values of java source and target in lines #130 and #132 to its previous values (“1.5″ and “1.6″)

*