Choosing a Java VM

The database server must be set up to locate a Java VM. Since you can specify different Java VMs for each database, the ALTER EXTERNAL ENVIRONMENT statement can be used to indicate the location (path) of the Java VM.

ALTER EXTERNAL ENVIRONMENT JAVA
LOCATION 'c:\\jdk1.5.0_06\\jre\\bin\\java.exe';

If the location is not set, the database server searches for the location of the Java VM, as follows:

  • Check the JAVA_HOME environment variable.

  • Check the JAVAHOME environment variable.

  • Check the path.

  • If the information is not in the path, return an error.

See ALTER EXTERNAL ENVIRONMENT statement.

Note

JAVA_HOME and JAVAHOME are environment variables commonly created when installing a Java VM. If neither of these exist, you can create them manually, and point them to the root directory of your Java VM. However, this is not required if you use the ALTER EXTERNAL ENVIRONMENT statement.

 To specify the location of the Java VM (Interactive SQL)
  1. Start Interactive SQL and connect to the database.

  2. In the SQL Statements pane, type the following statement:

    ALTER EXTERNAL ENVIRONMENT JAVA
    LOCATION 'path\\java.exe';

    Here, path indicates the location of the Java VM (for example, c:\\jdk1.5.0_06\\jre\\bin).

For more information, see ALTER EXTERNAL ENVIRONMENT statement.

Use the java_vm_options option to specify any additional command line options that are required to start the Java VM.

SET OPTION PUBLIC.java_vm_options='java-options';

For more information, see java_vm_options option.

If you want to use JAVA in the database, but do not have a Java Runtime Environment (JRE) installed, you can install and use any Java JRE that you want to. Once installed, it is best to set the JAVA_HOME or JAVAHOME environment variable to point to the root of the installed JRE. Note that most Java installers set one of these environment variables by default. Once a JRE is installed and JAVA_HOME or JAVAHOME is set correctly, you should then be able to use Java in the database without performing any additional steps.