# 22. Virtuoso Functions Guide - java_vm_attach

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
java_call_method
java_get_property
java_load_class
java_new_object
java_set_property
java_vm_attach
java_vm_detach
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## java_vm_attach

java_vm_attach (in classpath varchar, [in vm_options any]);
Description

Ensures that the current working thread is attached to the Java VM. It operates as follows:

- if the Java VM is not created it creates it.
- if the java VM is running, but the current working thread is not attached as a Java VM thread it attaches it.
- if none of the above it returns.

The java_vm_attach() function is called implicitly in each of the other VSEs, and also when allocating, copying or deleting a Virtuoso/PL reference to a Java VM object values.

If the Java VM is already initialized and the classpath is supplied it will throw a SQL error. If the Java VM is not initialized, but it is required to execute a statement the server will implicitly call java_vm_attach (NULL);. The Virtuoso Java VM integration binary works with JDK 1.2 and later.

Parameters
classpath – The classpath string to be supplied to the Java VM. If classpath is NULL the server OS environment variable CLASSPATH will be used instead.
vm_options – A vector of name/value pairs for the Java VM initialization parameters. The format and values of the parameters is described in the JNI Enhancements Introduced in version 1.2 of the JavaTM 2 SDK document - the description of JNI_CreateJavaVM Invocation API function.
Examples
Initializing the Java VM

This example initializes the Java VM by supplying a classpath of: CLASSPATH=/usr/local/virtuoso/classes:/usr/local/jakarta-tomcat-3.3.1/lib/tomcat.jar and sets the tomcat.home Java system property to /usr/local/jakarta-tomcat-3.3.1 It is the equivalent of executing JDK/JRE 1.2 unix java tool using: java -cp /usr/local/virtuoso/classes:/usr/local/jakarta-tomcat-3.3.1/lib/tomcat.jar -Dtomcat.home=/usr/local/jakarta-tomcat-3.3.1

    java_vm_attach ('/usr/local/virtuoso/classes:/usr/local/jakarta-tomcat-3.3.1/lib/tomcat.jar',
      vector ('-Dtomcat.home=/usr/local/jakarta-tomcat-3.3.1, 0);

See Also

java_call_method()

java_set_property()

java_get_property()

java_load_class()

java_new_object()

java_vm_detach()