class %Library.RunJava
extends %Library.RegisteredObject
This class contains convenient methods for running Java programs.
If the java executable on the system path is acceptable, then you can
leave the java home setting in sys mgmt portal blank. Otherwise you
should set it to the root directory of a supported JDK installation.
On Windows, if more than one JDK is installed, you should always set
the java home setting.
To test by hand if the java home setting is correct, type this in
a terminal window:
w ##class(%RunJava).getJDK(.sc,,$g(^%SYS("sql","sys","Java Home")))
w sc
The second result is '1' if the configured JDK is supported.
On Solaris, the standard java program is a 32-bit executable.
The use64Bit argument is only used on Solaris, and
the 64-bit java executable is only chosen if it is installed.
parameter JAVADEBUG = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=${JavaDebugPort},suspend=${JavaDebugSuspend},server=y";
Java debugging parameters:
(see http://java.sun.com/j2se/1.3/docs/guide/jpda/conninv.html#Xrunjdwp)
-Xdebug Enable debugging
-Xnoagent Disables oldjdb support
-Djava.compiler=NONE Disable JIT compiler
-Xrunjdwp: JDWP Options
transport=dt_socket, - Use TCP/IP
address=8000, - Listen on port 8000
suspend=y, - Suspend the Java process until the debugger connects
server=y - Listen for incoming debugger connection
property JavaDebug
as %Boolean [ InitialExpression = "0" ];
property JavaDebugPort
as %String(TRUNCATE=1) [ InitialExpression = "8000" ];
property JavaDebugSuspend
as %String(DISPLAYLIST=",Yes,No",TRUNCATE=1,VALUELIST=",y,n") [ InitialExpression = "n" ];
classmethod FindJava(pJavaHome As %String = "", use64Bit As %Boolean = 0)
as %String
Locate the java executable for a given JAVA_HOME
classmethod GetJavaCmd(pJavaHome As %String = "", pClassPath As %String = "", pJVMArgs As %String = "", pDebug As %Boolean = 0, pClass As %String, pArgs As %String = "", jdk As %String = "", debugPort As %String = "8000", debugSuspend As %Boolean = 0, use64Bit As %Boolean = 0)
as %String
Returns the command string necessary to run the java program.
classmethod JavaHome()
as %String
classmethod ReadJavaOutput(pJavaHome As %String = "", pClassPath As %String = "", pJVMArgs As %String = "", pDebug As %Boolean = 0, pClass As %String, pArgs As %String = "", jdk As %String = "", debugPort As %String = "8000", debugSuspend As %Boolean = 0, use64Bit As %Boolean = 0)
as %String
Returns the printed output of the java program as a string, using ReadProgramOutput.
classmethod ReadProgramOutput(tCmd As %String)
as %String
Returns the printed output of the program as a string.
Intended only for fast-running programs that generate relatively
small amounts of output.
classmethod RunJava(pJavaHome As %String = "", pClassPath As %String = "", pJVMArgs As %String = "", pDebug As %Boolean = 0, pClass As %String, pArgs As %String = "", jdk As %String = "", debugPort As %String = "8000", debugSuspend As %Boolean = 0, use64Bit As %Boolean = 0)
as %String
Spawns the java program as a separate process.
classmethod existJava(ByRef jv As %String = "", javaHome As %String = "")
as %Status
Test JDK directory to see if it contains a valid JDK.
Returns version information in jv
classmethod getCacheDbJarPath(jdk As %String = "")
as %String
Returns the path to the CacheDB.jar file corresponding to the version.
The version is returned by getJDK().
if jdk is null, returns path to the CacheDB.jar file in the lib subdirectory. This
jar file is used by default for Java Gateway.
classmethod getJDK(ByRef sc As %Status, ByRef jv As %String = "", javaHome As %String = "")
as %String
Returns the version string for the given JDK, for example: "JDK16"