This blog describes the steps needed to install and configure Oracle JVM for the Oracle 18c Database. The implementation described in this blog is based on a server installation with a minimum resource allocations required by Oracle and can also be used to install Oracle JVM for Oracle Database 11g/12c as well.
Oracle JVM Overview
Java has emerged as the object-oriented programming language of choice. Oracle Database provides support for developing, storing, and deploying Java applications: Oracle PL/SQL developers can develop server-side Java applications that take advantage of the scalability and performance of Oracle Database. The ability to run Java from within the Oracle database is possible as a result of the Oracle Java Virtual Machine (JVM) feature in the database. Few things to cover before we get started.
- Make sure you have SYS (with SYSDBA) access to the database
- Make sure you have a working Oracle 18c database provisioned, but without JVM component
Pre-Installation Steps
Before installing Oracle JVM, you must ensure that the configuration requirements for Oracle JVM are fulfilled. The main configuration for Java classes within Oracle Database includes configuring the:
- Java memory requirements: You must have at least 50 MB of JAVA_POOL_SIZE and 96 MB of SHARED_POOL_SIZE. You can also refer to the Oracle Doc for Java Memory Usage
- Database Processes: You must decide whether to use dedicated server processes or shared server processes for your database server.
Ensure ORACLE_HOME and ORACLE_SID environment variables are set on the database host
$ echo $ORACLE_SID
$ echo $ORACLE_HOME
Installation Steps
Connect to database instance as SYS (with SYSDBA privilege) to confirm status of OJVM. If “JAVAVM” is missing, then proceed.
SQL> SET wrap off
SQL> col comp_name format a20
SQL> SELECT comp_id, comp_name, status FROM dba_registry WHERE comp_id LIKE '%JAVA%';
no ROWS selected
SQL> EXIT;
On the OS, navigate to $ORACLE_HOME/javavm/install directory, then connect as to the database instance as SYS (with SYSDBA privilege).
$ cd $ORACLE_HOME/javavm/install
$ sqlplus / as sysdba
Run initjvm.sql script. The initjvm.sql script initializes JServer by installing core Java class libraries and Oracle-specific Java classes.
SQL> @initjvm.SQL
SQL> EXIT;
On the OS, navigate to $ORACLE_HOME/rdbms/admin directory, then connect as to the database instance as SYS (with SYSDBA privilege).
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus / as sysdba
Run catjava.sql script. The catjava.sql script installs Java-related packages and classes.
SQL> @catjava.SQL
Post-Installation Steps
Confirm Oracle JVM component is now installed.
SQL> SET wrap off
SQL> col comp_name format a20
SQL> SELECT comp_id, comp_name, status FROM dba_registry WHERE comp_id LIKE '%JAVA%';
COMP_ID COMP_NAME STATUS
------------------------------ -------------------- ---------------------------------
JAVAVM JServer JAVA Virtual VALID
CATJAVA Oracle DATABASE JAVA VALID