Skip Headers

Oracle9i Java Developer's Guide
Release 2 (9.2)

Part Number A96656-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

4
Java Installation and Configuration

This chapter describes what you need to know to install and configure Oracle JVM within your database. To configure Java memory, see the "Java Memory Usage" section in Chapter 6, "Oracle9i Java Application Performance".

Initializing a Java-Enabled Database

If you install Oracle9i with the Oracle JVM option, the database is Java-enabled. That is, it is ready to run Java stored procedures, JDBC, and SQLJ.

Oracle9i Database Template Configuration and Install

Configure the Oracle JVM option within the database template. This is the recommended method for Java installation.

The Oracle Database Configuration Assistant allows you to create database templates for defining what each database instance installation will contain. Choose the Oracle JVM option to have the Java platform installed within your database. See the Oracle Database Configuration Assistant documentation for more information on template creation.

Modifying an Existing Oracle9i Database to Include Oracle JVM

If you have already installed your Oracle9i database without Oracle JVM, you can add Java to your database through the modify mode of the Oracle9i Database Configuration Assistant. The modify mode enables you to choose the features, such as Oracle JVM, that you would like installed on top of an existing Oracle9i database.

Configuring Oracle JVM

When you install Oracle JVM as part of your normal Oracle9i installation, you will encounter configuration requirements for Oracle JVM within the Oracle9i Database Configuration Assistant and the Oracle Net Assistant.

The main configuration for Java classes within Oracle9i includes configuring Java memory requirements, the type of database processes, and the underlying connection protocol to the server.

Using The DBMS_JAVA Package

Installing Oracle JVM creates the PL/SQL package DBMS_JAVA. Some entrypoints of DBMS_JAVA are for your use; others are only for internal use. The corresponding Java class DbmsJava provides methods for accessing RDBMS functionality from Java.

The DBMS_JAVA package supplies the following entrypoints:

FUNCTION longname (shortname VARCHAR2) RETURN VARCHAR2

Return the full name from a Java schema object. Because Java classes and methods can have names exceeding the maximum SQL identifier length, Oracle JVM uses abbreviated names internally for SQL access. This function simply returns the original Java name for any (potentially) truncated name. An example of this function is to print the fully qualified name of classes that are invalid:

select dbms_java.longname (object_name) from user_objects 
   where object_type = 'JAVA CLASS' and status = 'INVALID';

FUNCTION shortname (longname VARCHAR2) RETURN VARCHAR2

You can specify a full name to the database by using the shortname() routine of the DBMS_JAVA package, which takes a full name as input and returns the corresponding short name. This is useful when verifying that your classes loaded by querying the USER_OBJECTS view.

Refer to "Shortened Class Names" and the Oracle9i Java Stored Procedures Developer's Guide for examples of these functions.

FUNCTION get_compiler_option(what VARCHAR2, optionName VARCHAR2)
PROCEDURE set_compiler_option(what VARCHAR2, optionName VARCHAR2,
value VARCHAR2)
PROCEDURE reset_compiler_option(what VARCHAR2, optionName VARCHAR2)

These three entry points control the options of the Oracle9i Java and SQLJ compiler that Oracle9i delivers. See "Compiling Java Classes" for an example of these options. Additionally, both theOracle9i Java Stored Procedures Developer's Guide and the Oracle9i SQLJ Developer's Guide and Reference document the options and these entry points.

PROCEDURE set_output (buffersize NUMBER)

This procedure redirects the output of Java stored procedures and triggers to the DBMS_OUTPUT package. See "Redirecting Output on the Server" for an example.

PROCEDURE loadjava(options varchar2)
PROCEDURE loadjava(options varchar2, resolver varchar2)
PROCEDURE dropjava(options varchar2)

These procedures allow you to load and drop classes within the database using a call, rather than through the loadjava or dropjava command-line tools. To execute within your Java application, do the following:

call dbms_java.loadjava('... options...');
call dbms_java.dropjava('... options...');

The options are identical to those specified for the loadjava and dropjava command-line tools. Each option should be separated by a blank. Do not separate the options with a comma. The only exception to this is the loadjava -resolver option, which contains blanks. For -resolver, specify all other options first, separate these options by a comma, and then specify the -resolver options, as follows:

call dbms_java.loadjava('... options...', 'resolver_options');

Do not specify the following options, because they relate to the database connection for the loadjava command-line tool: -thin, -oci, -user, -password. The output is directed to System.err. The output typically goes to a trace file, but can be redirected.

For more information on the available options, see Chapter 7, "Schema Object Tools" for complete information on loadjava.

PROCEDURE grant_permission( grantee varchar2,
permission_type varchar2,
permission_name varchar2,
permission_action varchar2 )

PROCEDURE restrict_permission( grantee varchar2,
permission_type varchar2,
permission_name varchar2,
permission_action varchar2)

PROCEDURE grant_policy_permission( grantee varchar2,
permission_schema varchar2,
permission_type varchar2,
permission_name varchar2)

PROCEDURE revoke_permission(permission_schema varchar2,
permission_type varchar2,
permission_name varchar2,
permission_action varchar2)

PROCEDURE disable_permission(key number)

PROCEDURE enable_permission(key number)

PROCEDURE delete_permission(key number)

These entry points control the JVM permissions. See "Setting Permissions" for a description and example of these options.

PROCEDURE start_debugging(host varchar2, port number,
timeout number)

PROCEDURE stop_debugging

PROCEDURE restart_debugging(timeout number)

These entry points start and stop the debug agent when debugging. See "Debugging Server Applications" for a description and example of these options.

Enabling the Java Client

To run Java between the client and server, your client system must perform the following:

1. Install JDK on the Client.

2. Set up Environment Variables.

3. Test Install with Samples.

1. Install JDK on the Client

The client requires JDK 1.1.6 or later. To confirm what version of the JDK you are using, perform the following:

$ which java
/usr/local/packages/jdk1.2.1/bin/java 
$ which javac 
/usr/local/packages/jdk1.2.1/bin/javac 
$ java -version
java version "1.2.1"

2. Set up Environment Variables

After installing the JDK on your client, you must add the directory path to the following environment variables:


Note:

For NT users, the syntax for the environment variables is
%ORACLE_HOME%, %JAVA_HOME%, %PATH%, and %LIB%.


JAR Files Necessary for JDK 1.1 Clients

For a JDK 1.1 client to communicate with the Java 2 server, you must include the following JVM JAR file:

$JAVA_HOME/lib/classes.zip

For any interaction with JDBC, include the following ZIP file:

$ORACLE_HOME/jdbc/lib/classes111.zip

For any client that uses SSL, include the following JAR files:

$ORACLE_HOME/jlib/jssl-1_1.jar 
$ORACLE_HOME/jlib/javax-ssl-1_1.jar 

For any client that uses Java Transaction API (JTA) functionality, include the following JAR file:

$ORACLE_HOME/jlib/jta.jar

For any client that uses JNDI functionality, include the following JAR file:

$ORACLE_HOME/jlib/jndi.jar

JAR Files Necessary for Java 2 Clients

For a Java 2 client to communicate with the Java 2 server, you must make sure that one of the following JVM JAR files are in the CLASSPATH:

For any interaction with JDBC, include the following ZIP file:

$ORACLE_HOME/jdbc/lib/classes12.zip

For any client that uses SSL, include the following JAR files:

$ORACLE_HOME/jlib/jssl-1_2.jar 
$ORACLE_HOME/jlib/javax-ssl-1_2.jar 

For any client that uses Java Transaction API (JTA) functionality, include the following JAR file:

$ORACLE_HOME/jlib/jta.jar

For any client that uses JNDI functionality, include the following JAR file:

$ORACLE_HOME/jlib/jndi.jar

If you are using the Accelerator for native compilation, include $JAVA_HOME/lib/tools.jar

JAR Files Included for Clients that use SQLJ

$ORACLE_HOME/sqlj/lib/translator.zip

In addition to this file, add the appropriate runtimeX.zip file, as follows:

Server Application Development on the Client

If you develop and compile your server applications on the client and you want to use the same JAR files that are loaded on the server, include $ORACLE_HOME/lib/aurora.zip in the CLASSPATH. This is not required for running Java clients.

3. Test Install with Samples

We provide a set of samples in the $ORACLE_HOME/javavm/demo directory. These samples compile and run for a database installed with the Oracle JVM option. Execute these samples as a test of your installation.

$ORACLE_HOME/javavm/demo/examples/jsproc/helloworld

If these samples do not compile or run, your environment is incorrect. Similarly, if these samples compile and run, but your code does not, then a problem exists within your build environment or code.


Note:

It is important that you run these examples using the supplied Makefiles (or batch files on NT) when verifying your installation.


Verify that the samples work before using more complex build environments, such as Visual Cafe, JDeveloper, or VisualAge.


Go to previous page Go to next page
Oracle
Copyright © 2000, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback