RunConfigurations49636
Demo Script
Prerequisites:
-
NetBeans 6.0 (tested against 20070419 ~ M9)
-
JDK 6.0u1
-
Any supported OS (tested on Ubuntu)
-
Preparation:
-
Create a Java application.
-
Add to the main method:
-
System.out.println("First main class.");
-
Add a new Java main class. Add to its main method:
System.out.println("Second main class.");
-
Click Run (F6). You should see
run:
First main class.
BUILD SUCCESSFUL
Demo steps:
-
From the <default> combo in the toolbar, select Customize….
-
Click New… (configuration).
-
Enter name
second
and click OK. -
Click Browse… (for main class).
-
Pick the second class and click Select Main Class.
-
Click OK to close the Properties dialog.
-
Click Run; you should see
-
run:
Second main class.
BUILD SUCCESSFUL
-
Choose <default> again in the combo and click Run; you should see the first main class again.
-
Right-click the project and choose Properties.
-
Under Run, switch to second configuration.
-
Add
-showversion
to VM Options. Note that the field’s label becomes boldfaced. -
Click OK and Run; you should see
-
run:
java version "1.6.0_01"
JavaTM SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpotTM Server VM (build 1.6.0_01-b06, mixed mode)
Second main class.
BUILD SUCCESSFUL
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/second.properties
. Add:
build.compiler=extJavac
javac.compilerargs=-J-showversion
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)
compile:
Generally, anything normally set in project.properties
can be overridden on a
per-configuration basis. The Properties dialog outside the Run panel will
only show the contents of project.properties
, however.