Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » Tutorial: Using Java in the Database » Introduction to Java in the Database tutorial

Creating and compiling the sample Java class Next Page

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 java_location option can be used to indicate the location (path) of the Java VM. See java_location option [database].

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

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 java_location option. See java_location option [database].

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 command:

    SET OPTION PUBLIC.java_location='path\java.exe';

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

  3. You can also set the java_main_userid option to specify the database user whose connection can be used for installing classes and performing other Java-related administrative tasks. Use the java_vm_options option to specify any additional command line options that are required to start the Java VM. See java_main_userid option [database], and java_vm_options option [database].

    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 wish. 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.

    On NetWare, which does not use environment variables, either install the JRE in the path, or set the java_location option accordingly. See java_location option [database].