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.
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 String s |
PROP_APPLICATION_ARGS | application arguments | Iterable of String s |
JavaRunnerImplementation
Modifier and Type | Field and Description |
---|---|
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_EXECUTE_MODULEPATH
Execute modulepath to use for execution of the class.
|
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_PROFILE
"Test" run the given file in the profiling mode.
|
static String |
QUICK_PROFILE_APPLET
"Test" run the given applet in the profiling 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.
|
static String |
QUICK_TEST_PROFILE
"Test" run the given test in the profiling mode.
|
Constructor and Description |
---|
JavaRunner() |
Modifier and Type | Method and Description |
---|---|
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.
|
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
.
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.
public static final String QUICK_PROFILE
"Test" run the given file in the profiling 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
.
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.
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
.
public static final String QUICK_TEST_PROFILE
"Test" run the given test in the profiling 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.
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
.
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
.
public static final String QUICK_PROFILE_APPLET
"Test" run the given applet in the profiling 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
.
public static final String QUICK_CLEAN
public static final String PROP_EXECUTE_FILE
String
(absolute path) or FileObject
.public static final String PROP_WORK_DIR
public static final String PROP_RUN_JVMARGS
Iterable
of String
s.
Arguments may also be contributed by StartupExtender
s;
the JavaPlatform
(see PROP_PLATFORM
) will be in the context,
as will a Project
if available from PROP_EXECUTE_FILE
or PROP_WORK_DIR
.
public static final String PROP_CLASSNAME
String
- fully qualified binary name.
Will be autodetected from PROP_EXECUTE_FILE
if missing.public static final String PROP_EXECUTE_CLASSPATH
ClassPath
.
Will be autodetected from PROP_EXECUTE_FILE
if missing.public static final String PROP_EXECUTE_MODULEPATH
ClassPath
.
Will be autodetected from PROP_EXECUTE_FILE
if missing.public static final String PROP_PLATFORM_JAVA
String
(absolute path) or FileObject
or File
.
Will be autodetected from PROP_PLATFORM
if missing.public static final String PROP_PLATFORM
JavaPlatform
.
Will be used to autodetect PROP_PLATFORM_JAVA
.public static final String PROP_PROJECT_NAME
String
.
Will be autodetected from PROP_EXECUTE_FILE
if missing.public static final String PROP_APPLICATION_ARGS
public static final String PROP_RUNTIME_ENCODING
FileEncodingQuery
is used
to obtain the encoding.public static boolean isSupported(String command, Map<String,?> properties)
command
- command nametoRun
- either the file that would be executed, or the project folderpublic static ExecutorTask execute(String command, Map<String,?> properties) throws IOException, UnsupportedOperationException
command
- command to executeprops
- propertiestoRun
- file to runIOException
- if execution failsUnsupportedOperationException
- if the given command is not supportedBuilt on October 25 2023. | Copyright © 2017-2023 Apache Software Foundation. All Rights Reserved.