CreateJavaVM
Description
Loads and initializes a Java VM or attaches an existing Java VM to
the current process.
Syntax
|
1 |
javavm.createJavaVM(string classpath, boolean isdebug) |
|
Argument |
Description |
|---|---|
|
javavm |
An instance of the JavaVM class |
|
classpath |
A string specifying the classpath that contains |
|
isdebug |
A boolean that determines whether debug information |
Return value
Integer.
Returns one of the following integer values:
1 — Success. The Java VM had already been loaded and was attached
to the current process.
0 — Success. The Java VM was loaded and initialized and attached
to the current process.
-1 — Failure. The Java VM was not loaded, possibly because
jvm.dll was not found in the classpath.
-2 — Failure. The pbejbclient180.jar file was not found.
Examples
This example shows how createJavaVM might be used with a
connection to WebLogic:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
JavaVM l_jvm EJBConnection l_ejbconn java_integer val l_jvm = CREATE JavaVM l_EJBConn = CREATE EJBConnection TRY IF l_jvm.createJavaVM("", false) >= 0 THEN string ls_props[] ls_props[1] = "javax.naming.Context.INITIAL_CONTEXT_FACTORY= weblogic.jndi.WLInitialContextFactory" ls_props[2] ="javax.naming.Context.PROVIDER_URL=t3://svr1:7001" ls_props[3] = "javax.naming.Context.SECURITY_PRINCIPAL=myid" ls_props[4] = "javax.naming.Context.SECURITY_CREDENTIALS=mypass" l_EJBConn.connectToServer(ls_props) l_EJBConn.createJavaInstance(val, "java_integer") val.java_integer(17) MessageBox("The value is", val.IntValue()) ELSE MessageBox("createJavaVM", "Failed", StopSign!) END IF CATCH (Throwable g) MessageBox("Exception in createJavaInstance", g.getMessage()) END TRY |
Usage
The isdebug argument is used to record information about the Java
VM, including class loads, in the file VM.out in the directory where the
current application is located.
The classpath argument must include the classes and JAR files
required by the server, if they are not already listed in the classpath
used by the Java VM.
Classpath argument has no effect if the JVM is already
running
Files and directories passed only in the classpath argument are
not available to the Java VM if it has already been started by another
process. In the development environment, you can check whether the
Java VM is running and, if so, which classpath it is using, on the
Java page of the System Options dialog box. At runtime, you can use
the IsJavaVMLoaded method to
determine whether the Java VM is already running, and the GetJavaClasspath method
to find the classpath.
In the development environment, the classpath used by the Java VM
is constructed by concatenating these paths:
-
A classpath added programmatically when the JVM is started.
For example, the classpath you pass to this method. -
The PowerBuilder runtime static registry classpath. This path
is built into the pbjvm180.dll and contains classes required at
runtime for features such as PDF generation and EJB clients. -
The PowerBuilder system classpath. This path resides in a
Windows registry key installed when you install PowerBuilder. It
contains classes required at design time for Java-related
PowerBuilder features. -
The PowerBuilder user classpath. This is the path that you
specify on the Java page of the System Options dialog box. -
The system CLASSPATH environment variable.
-
The current directory.
The JVM uses the following classpath at runtime:
-
A classpath added programmatically when the JVM is
started -
The PowerBuilder runtime static registry classpath
-
The system CLASSPATH environment variable
-
The current directory
See also