org.netbeans.modules.java.project/1 1.38.1

org.netbeans.api.java.project.runner
Class JavaRunner

java.lang.Object
  extended by org.netbeans.api.java.project.runner.JavaRunner

public final class JavaRunner
extends Object

Class that allows to execute given file(s). API clients can check whether given command is support, by calling #isSupported(String) and execute the command by calling execute(String, Map). Please consult documentation of particular commands for the list of supported properties.

The following "standard" properties are supported by most commands (unless stated otherwise):
PROP_EXECUTE_FILE file to be executed (optional) String (absolute path) or FileObject
PROP_WORK_DIR working directory, project directory of execute.file will be used if missing String or FileObject or File
PROP_CLASSNAME class to execute, will be autodetected from execute.file if missing String
PROP_EXECUTE_CLASSPATH execute classpath, will be autodetected from execute.file if missing ClassPath
PROP_PLATFORM_JAVA java tool which should be used for execution, will be autodetected from platform property if missing String or FileObject or File
PROP_PLATFORM java platform on which the class should be executed, default if missing, not needed if platform.java is set JavaPlatform
PROP_PROJECT_NAME name of the current project, will be autodetected from execute.file if missing String
PROP_RUN_JVMARGS JVM arguments Iterable of Strings
PROP_APPLICATION_ARGS application arguments Iterable of Strings

Since:
1.22
See Also:
JavaRunnerImplementation

Field Summary
static String PROP_APPLICATION_ARGS
          Application arguments to be used for the execution.
static String PROP_CLASSNAME
          The name of the class to execute.
static String PROP_EXECUTE_CLASSPATH
          Execute classpath to use for execution of the class.
static String PROP_EXECUTE_FILE
          File to execute.
static String PROP_PLATFORM
          Java platform to use for execution.
static String PROP_PLATFORM_JAVA
          Java tool to use for execution.
static String PROP_PROJECT_NAME
          Project name to use for Output Window caption.
static String PROP_RUN_JVMARGS
          JVM arguments to be used for the execution.
static String PROP_RUNTIME_ENCODING
          Runtime file encoding passed to the jvm (-Dfile.encoding).
static String PROP_WORK_DIR
          Working directory for execution.
static String QUICK_CLEAN
          Clean classfiles produced by the Java infrastructure.
static String QUICK_DEBUG
          "Test" run the given file in the debugging mode.
static String QUICK_DEBUG_APPLET
          "Test" run the given applet in debugging mode.
static String QUICK_RUN
          "Test" run the given file.
static String QUICK_RUN_APPLET
          "Test" run the given applet.
static String QUICK_TEST
          "Test" run the given test.
static String QUICK_TEST_DEBUG
          "Test" run the given test in the debugging mode.
 
Constructor Summary
JavaRunner()
           
 
Method Summary
static ExecutorTask execute(String command, Map<String,?> properties)
          Execute the given command with given parameters.
static boolean isSupported(String command, Map<String,?> properties)
          Check whether the given command is supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUICK_RUN

public static final String QUICK_RUN

"Test" run the given file. Classfiles produced by the Java infrastructure will be executed.

These properties are should be set in the properties, or inferable: PROP_EXECUTE_CLASSPATH, PROP_CLASSNAME, PROP_PLATFORM_JAVA, PROP_WORK_DIR, PROP_RUN_JVMARGS and PROP_APPLICATION_ARGS.

Since:
1.22
See Also:
Constant Field Values

QUICK_DEBUG

public static final String QUICK_DEBUG

"Test" run the given file in the debugging mode. Classfiles produced by the Java infrastructure will be executed.

These properties are should be set in the properties, or inferable: PROP_EXECUTE_CLASSPATH, PROP_CLASSNAME, PROP_PLATFORM_JAVA, PROP_WORK_DIR, PROP_RUN_JVMARGS and PROP_APPLICATION_ARGS.

Property stopclassname can be set to a classname to support starting debugger using the Step Into command.

Since:
1.22
See Also:
Constant Field Values

QUICK_TEST

public static final String QUICK_TEST

"Test" run the given test. Classfiles produced by the Java infrastructure will be executed.

These properties are should be set in the properties, or inferable: PROP_EXECUTE_CLASSPATH, PROP_CLASSNAME, PROP_PLATFORM_JAVA, PROP_WORK_DIR and PROP_RUN_JVMARGS.

application.args property is not supported.

Since:
1.22
See Also:
Constant Field Values

QUICK_TEST_DEBUG

public static final String QUICK_TEST_DEBUG

"Test" run the given test in the debugging mode. Classfiles produced by the Java infrastructure will be executed.

These properties are should be set in the properties, or inferable: PROP_EXECUTE_CLASSPATH, PROP_CLASSNAME, PROP_PLATFORM_JAVA, PROP_WORK_DIR and PROP_RUN_JVMARGS.

application.args property is not supported.

Since:
1.22
See Also:
Constant Field Values

QUICK_RUN_APPLET

public static final String QUICK_RUN_APPLET

"Test" run the given applet. Classfiles produced by the Java infrastructure will be executed.

These properties are should be set in the properties, or inferable: PROP_EXECUTE_CLASSPATH, PROP_EXECUTE_FILE, PROP_PLATFORM_JAVA, PROP_WORK_DIR and PROP_RUN_JVMARGS, applet.url.

Since:
1.22
See Also:
Constant Field Values

QUICK_DEBUG_APPLET

public static final String QUICK_DEBUG_APPLET

"Test" run the given applet in debugging mode. Classfiles produced by the Java infrastructure will be executed.

These properties are should be set in the properties, or inferable: PROP_EXECUTE_CLASSPATH, PROP_EXECUTE_FILE, PROP_PLATFORM_JAVA, PROP_WORK_DIR and PROP_RUN_JVMARGS, applet.url.

Since:
1.22
See Also:
Constant Field Values

QUICK_CLEAN

public static final String QUICK_CLEAN
Clean classfiles produced by the Java infrastructure.

Since:
1.22
See Also:
Constant Field Values

PROP_EXECUTE_FILE

public static final String PROP_EXECUTE_FILE
File to execute. Should be either String (absolute path) or FileObject.

Since:
1.22
See Also:
Constant Field Values

PROP_WORK_DIR

public static final String PROP_WORK_DIR
Working directory for execution. Should be either String (absolute path) or FileObject or File.

Since:
1.22
See Also:
Constant Field Values

PROP_RUN_JVMARGS

public static final String PROP_RUN_JVMARGS
JVM arguments to be used for the execution. Should be an Iterable of Strings.

Since:
1.22
See Also:
Constant Field Values

PROP_CLASSNAME

public static final String PROP_CLASSNAME
The name of the class to execute. Should be String - fully qualified binary name. Will be autodetected from PROP_EXECUTE_FILE if missing.

Since:
1.22
See Also:
Constant Field Values

PROP_EXECUTE_CLASSPATH

public static final String PROP_EXECUTE_CLASSPATH
Execute classpath to use for execution of the class. Should be ClassPath. Will be autodetected from PROP_EXECUTE_FILE if missing.

Since:
1.22
See Also:
Constant Field Values

PROP_PLATFORM_JAVA

public static final String PROP_PLATFORM_JAVA
Java tool to use for execution. Should be String (absolute path) or FileObject or File. Will be autodetected from PROP_PLATFORM if missing.

Since:
1.22
See Also:
Constant Field Values

PROP_PLATFORM

public static final String PROP_PLATFORM
Java platform to use for execution. Should be JavaPlatform. Will be used to autodetect PROP_PLATFORM_JAVA.

Since:
1.22
See Also:
Constant Field Values

PROP_PROJECT_NAME

public static final String PROP_PROJECT_NAME
Project name to use for Output Window caption. Should be String. Will be autodetected from PROP_EXECUTE_FILE if missing.

Since:
1.22
See Also:
Constant Field Values

PROP_APPLICATION_ARGS

public static final String PROP_APPLICATION_ARGS
Application arguments to be used for the execution. Should be an Iterable of Strings.

Since:
1.22
See Also:
Constant Field Values

PROP_RUNTIME_ENCODING

public static final String PROP_RUNTIME_ENCODING
Runtime file encoding passed to the jvm (-Dfile.encoding). If not given the FileEncodingQuery is used to obtain the encoding.

Since:
1.28
See Also:
Constant Field Values
Constructor Detail

JavaRunner

public JavaRunner()
Method Detail

isSupported

public static boolean isSupported(String command,
                                  Map<String,?> properties)
Check whether the given command is supported.

Parameters:
command - command name
toRun - either the file that would be executed, or the project folder
Returns:
true if and only if the given command is supported for given file/folder
Since:
1.22

execute

public static ExecutorTask execute(String command,
                                   Map<String,?> properties)
                            throws IOException,
                                   UnsupportedOperationException
Execute the given command with given parameters. Please refer to the documentation of the given command for supported properties.

Parameters:
command - command to execute
props - properties
toRun - file to run
Throws:
IOException - if execution fails
UnsupportedOperationException - if the given command is not supported
Since:
1.22

org.netbeans.modules.java.project/1 1.38.1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.