Using Oracle Java on Autonomous Database

Autonomous 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 Database adheres to standard Java language semantics, including dynamic class loading at run time.

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

Enable Oracle Java

Use DBMS_CLOUD_ADMIN.ENABLE_FEATURE to enable Oracle Java on Autonomous 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 Database instance.

    See ENABLE_FEATURE Procedure for more information.

  2. Restart the Autonomous Database instance.

    See Restart Autonomous Database for more information.

After you restart the Autonomous Database instance, Oracle JVM is enabled on the instance.

Check Oracle Java Version

You can check the Oracle Java version and the component registry for information on Oracle Java in the Autonomous 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.

  2. Check the Oracle Java JDK version.
    SELECT dbms_java.get_jdk_version FROM DUAL;
    
    GET_JDK_VERSION
    --------------- 
    1.8.0_331

Load Java classes and JAR Files into Autonomous Database

You can use the client-side loadjava option to load Java classes and JAR files into Oracle JVM on an Autonomous 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 Database.
  3. The Java code is submitted to the Oracle JVM running on the Autonomous 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:

  • The Java code you load cannot invoke any operating system or network calls.

  • Use of server-side loadjava, that is calls to the procedure dbms_java.loadjava is not supported. The procedure dbms_java.loadjava accesses the file system of the database server where the Oracle JVM runs. This is not allowed on Autonomous Database and calls to the procedure dbms_java.loadjava from within your Java application are not supported.

Notes for Oracle Java on Autonomous Database

Provides notes for using Oracle Java on Autonomous Database.

  • You cannot disable Oracle Java after it is enabled on the Autonomous Database instance.

  • Autonomous Database performs Oracle Java patching, as required, during the regular Autonomous Database maintenance window.

    During Oracle Java patching, Java is not available and users could get an error similar to the following:

    ERROR at line 1:
    ORA-29548: Java system class reported: release of Java system classes in the
    database (19.0.0.0.220118 1.8) does not match that of the oracle executable
    (19.0.0.0.220419 1.8).

    During the maintenance window, when the Java patching phase is active there is no response for Java session calls or you see the ORA-29548 error. After the maintenance window completes, Java usage is restored.

    You can use the events NewMaintenanceSchedule and ScheduledMaintenanceWarning to be notified of Oracle Java patching. See Information Events on Autonomous Database for more information.

    See About Scheduled Maintenance and Patching for more information.