blob: 39bf6162d011a94f0c039038b1010e3a3b55e3b5 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= RunConfigurations49636
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:markup-in-source: verbatim,quotes,macros
:jbake-status: published
:syntax: true
:description: Run Configurations for Java SE Projects
:icons: font
:source-highlighter: pygments
:toc: left
:toc-title:
:experimental:
== Run Configurations for Java SE Projects
Links:
* link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectapi/org/netbeans/spi/project/doc-files/configurations.html[Technical specification]
* link:http://www.netbeans.org/nonav/issues/show_bug.cgi?id=49636[Tracking issue for Java SE projects]
* link:http://www.netbeans.org/nonav/issues/show_bug.cgi?id=49652[Tracking issue for API]
* link:NewAndNoteWorthyMilestone3#RunConfigurationsForJavaSEProjects.html[Release note]
[[Demo_Script]]
== Demo Script
Prerequisites:
1. NetBeans 6.0 (tested against 20070419 ~ M9)
. JDK 6.0u1
. Any supported OS (tested on Ubuntu)
Preparation:
1. Create a Java application.
. Add to the main method:
[source,java]
----
System.out.println("First main class.");
----
. Add a new Java main class. Add to its main method:
[source,java]
----
System.out.println("Second main class.");
----
. Click *Run* (F6). You should see
[source,bash]
----
run:
First main class.
BUILD SUCCESSFUL
----
Demo steps:
1. 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
[source,bash]
----
run:
Second main class.
BUILD SUCCESSFUL
----
1. 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
[source]
----
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]]
== 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:
[source,bash]
----
build.compiler=extJavac
javac.compilerargs=-J-showversion
----
With the configuration set to *second*, press *Clean and Build Main Project* (S-F11). You should see
[source,bash]
----
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.
[NOTE]
====
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/RunConfigurations49636[http://wiki.netbeans.org/RunConfigurations49636] ,
that was last modified by NetBeans user Jglick
on 2010-02-19T17:02:01Z.
This document was automatically converted to the AsciiDoc format on 2020-03-12, and needs to be reviewed.
====