Products Docs & Support Community

Getting Started with OpenJDK in NetBeans IDE

Several pieces of Sun's Java Development Kit (JDK) have been open-sourced and are now available for you to download, browse, and build. The best way to work with the OpenJDK sources is in the NetBeans IDE.

This tutorial shows you how to get started with the OpenJDK project sources and work with them in the IDE.

Overview

The sources for the following 9 projects have been organized into NetBeans projects. In the case of the following five projects, all you have to do is download them (they're included with the OpenJDK sources), open them in the IDE, and use the Build Project command to build them.
  • Javac Compiler. This project works with the source code for the Java programming language compiler, javac, which compiles Java source code into bytecode class files.
  • Javadoc. The sources in this project involve the javadoc tool, which parses the declaration and documentation comments in a set of Java source files and produces a set of HTML pages describing the classes, interfaces, constructors, methods, and fields.
  • JConsole. The sources in this project cover JConsole. JConsole is a GUI monitoring tool that complies to the JMX specification. The JConsole API provides a programmatic interface to access JConsole.
  • JMX. The sources in the JMX project cover the Java Management Extensions (JMX) API, which is a standard Java API for management and monitoring of resources such as applications, devices, services, and the Java virtual machine.
  • Swing. The sources in this project address the all-Java Swing user interface components.

The following four projects, also included with the OpenJDK sources, require the use of a Make utility in order for you to build them:

Note: For the above four projects, the instructions in these tutorials have been optimized for Linux distributions and for OpenSolaris. For details, see Setting Up an Environment for the NetBeans Make-Based OpenJDK Projects.

The sources for JavaHelp, the Java help system, are also available.

When encountering problems of any kind, please consult the Troubleshooting Guide.

Getting the Sources

  1. Download the source ZIP file
and unzip it to any location on your computer.

Note: Make sure the project location does not contain a space in the path. For example, do not use the Documents and Settings folder on Windows machines.

  • Open NetBeans IDE and choose File > Open Project.

    Note: Make sure that you are using NetBeans IDE 6.0 (until the final release, use a milestone build).

  • Navigate to the directory where you unzipped the sources. You should find the following directory structure:
    <install-dir>/
      control/
      hotspot/
      j2se/
        build
          .../
          .../
          .../
        dist
          .../
          .../
          .../
        make/
          .../
          .../
          .../
          netbeans/
            awt2d/
            common/
            compiler/
            j2se/
            jarzip/
            javadoc/
            jconsole/
            jmx/
            swing/
            world/
            README
          .../
          .../
          .../        
        src/
            test/

    The highlighted folders above are those that provide NetBeans projects. The "common" folder contains information shared between the projects. Later, when you build a project, the output is written to the dist and build folders, shown in italics above, which are created at that time.

  • Select the project that you would like to work on, and click OK. The sources open as a NetBeans project in the Projects window.

    Note: The very first time you open any one of the OpenJDK projects, the IDE will scan the entire set of sources, not just those for the project you opened. This will take a few minutes, but will ensure that Go To Type, Go To Source, and so on, will work as expected.

    If you open all the projects, the Projects window looks as shown below. Notice that each project comes with its own README, as shown here:

    javac project open in 
        projects window

  • Congratulations, you have now set up one or more of the NetBeans OpenJDK projects and are ready to begin working with them.

    Getting to Know the NetBeans OpenJDK Projects

    The following tutorials assume that you have read and understood the previous sections and that you have opened the project in question.

    The individual NetBeans OpenJDK project tutorials are as follows:

    Setting Up a Test Environment

    The test harness that you can use with the OpenJDK NetBeans projects is jtreg. Download it here:

    Once you have downloaded jtreg, define the jtreg.home property in the build.properties file, which is described in Setting Up an Environment for the NetBeans Make-Based OpenJDK Projects. The jreg.home property should point to the directory containing your unzipped jtreg sources, such as the following:

    jtreg.home=/home/jtreg

    When jtreg is set up as described above, you can right-click a project in the IDE and choose Test Project. Alternatively, you can right-click an individual file and choose Run File. The latter runs a jtreg test on an individual file.

    jtreg prints summary output about the pass/fail nature of each test. HTML files with the results are written to the jtreg folder within the j2se/build folder.