Use Oracle Java on Autonomous AI Database

Autonomous AI Database supports Oracle JVM. Oracle JVM is a standard, Java-compatible environment that runs any pure Java application.

Oracle JVM is compatible with the standard JLS and the JVM specifications. It supports the standard Java binary format and the standard Java APIs. In addition, Oracle AI Database adheres to standard Java language semantics, including dynamic class loading at run time.

See About Using Java in Oracle AI Database for information on Oracle Java.

Enable Oracle Java

Use DBMS_CLOUD_ADMIN.ENABLE_FEATURE to enable Oracle Java on Autonomous AI Database.

  1. Run DBMS_CLOUD_ADMIN.ENABLE_FEATURE.

    BEGIN
       DBMS_CLOUD_ADMIN.ENABLE_FEATURE(
           feature_name => 'JAVAVM' );
    END;
    /

    This initiates the request to install Oracle Java on the Autonomous AI Database instance.

    See ENABLE_FEATURE Procedure for more information.

  2. Restart the Autonomous AI Database instance.

    See Restart Autonomous AI Database for more information.

After you restart the Autonomous AI Database instance, the Java installation proceeds for some time after the database starts. See Check Oracle Java Version to verify that Oracle JVM is enabled and the installation is complete.

Check Oracle Java Version

You can check the Oracle Java version and the component registry for information on Oracle Java in the Autonomous AI Database instance.

  1. Check the component registry status and version for Oracle Java.

    SELECT status, version FROM DBA_REGISTRY
       WHERE comp_id = 'JAVAVM';
    
    STATUS VERSION
    
    ------ ----------
    VALID  19.0.0.0.0

    If Oracle Java is not installed, this query shows no rows.

    If Oracle Java is loading this query shows status LOADING. For example:

    STATUS  VERSION
    
    ------- -------
    LOADING null
  2. Check the Oracle Java JDK version.

    SELECT dbms_java.get_jdk_version FROM DUAL;
    
    GET_JDK_VERSION
    
    ---------------
    1.8.0_411

    If Oracle Java is not installed, this query shows an error message.

Load Java classes and JAR Files into Autonomous AI Database

You can use the client-side loadjava option to load Java classes and JAR files into Oracle JVM on an Autonomous AI Database instance.

The client-side loadjava option is supported as follows:

  1. The JDK opens the JAR file.

  2. The client-side opens a communication channel with the Autonomous AI Database.

  3. The Java code is submitted to the Oracle JVM running on the Autonomous AI Database for loading.

This process is similar to creating a dynamic Java stored procedure from SQL code, where no file access is involved, but the code gets created.

Note the following:

Notes for Oracle Java on Autonomous AI Database

Provides notes for using Oracle Java on Autonomous AI Database.