Run Configurations for Java SE Projects


Demo Script


  1. NetBeans 6.0 (tested against 20070419 ~ M9)
  2. JDK 6.0u1
  3. Any supported OS (tested on Ubuntu)


  1. Create a Java application.
  2. Add to the main method:
System.out.println("First main class.");
  1. Add a new Java main class. Add to its main method:
System.out.println("Second main class.");
  1. Click Run (F6). You should see
First main class.

Demo steps:

  1. From the <default> combo in the toolbar, select Customize....
  2. Click New... (configuration).
  3. Enter name second and click OK.
  4. Click Browse... (for main class).
  5. Pick the second class and click Select Main Class.
  6. Click OK to close the Properties dialog.
  7. Click Run; you should see
Second main class.
  1. Choose <default> again in the combo and click Run;
 you should see the first main class again.
  1. Right-click the project and choose Properties.
  2. Under Run, switch to second configuration.
  3. Add -showversion to VM Options. Note that the field's label becomes boldfaced.
  4. Click OK and Run; you should see
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Server VM (build 1.6.0_01-b06, mixed mode)

Second main class.

Optional material

Question: Can I control other things besides Run options?

Answer: You can, though for at least for 6.0 this is not supported through the GUI. For example, go to the Files tab and open nbproject/configs/ Add:


With the configuration set to second, press Clean and Build Main Project (S-F11). You should see

Compiling 2 source files to /tmp/JavaApplication1/build/classes
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)


Generally, anything normally set in can be overridden on a per-configuration basis. The Properties dialog outside the Run panel will only show the contents of, however.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo