I recently thought of using a Java method in PL/SQL. And so I wrote the Java stored procedure and ran it on Oracle XE.
Things didn’t go as planned.
SQL> -- Create java source for GCD calculation SQL> create or replace and resolve java source named "BigInt" as 2 import java.math.BigInteger; 3 public class BigInt 4 { 5 public static i gcd(int i1, int i2) 6 { 7 BigInteger b1 = BigInteger.valueOf(i1); 8 BigInteger b2 = BigInteger.valueOf(i2); 9 return b1.gcd(b2).intValue(); 10 } 11 }; 12 / create or replace and resolve java source named "BigInt" as * ERROR at line 1: ORA-29538: Java not installed
ORA-29538: Java not installed
Should have checked first if JVM is present in the Oracle instance I’m using.
How to check if JVM is installed in Oracle
Method 1: Check ALL_REGISTRY_BANNERS
The view ALL_REGISTRY_BANNERS displays a summary view of the valid components loaded into the Oracle database. It contains a single text column BANNER with details about each component.
Let’s see what ALL_REGISTRY_BANNERS says:
SQL> select * from all_registry_banners; BANNER ------------------------------------------------------------------- Oracle Database Catalog Views Release 11.2.0.2.0 - 64bit Production Oracle Database Packages and Types Release 11.2.0.2.0 - Development Oracle Text Release 11.2.0.2.0 - Development Oracle XML Database Version 11.2.0.2.0 - Development Oracle Application Express Release 4.0.2.00.09 - Development
When JVM is installed and valid, we should also see these lines in ALL_REGISTRY_BANNERS:
BANNER ------------------------------------------------------------------- JServer JAVA Virtual Machine Release 11.2.0.4.0 - Development Oracle Database Java Packages Release 11.2.0.4.0 - Development
These lines did not appear in ALL_REGISTRY_BANNERS, which means JVM is missing or invalid.
Method 2: Check DBA_REGISTRY
The view DBA_REGISTRY displays details of components loaded into the Oracle database: the component’s id, name, status (VALID, INVALID, DOWNGRADED, etc.) and other information such as the date-time of last modification, whether the component requires a startup after the upgrade or not.
Listing the relevant columns from DBA_REGISTRY to check for JVM presence:
SQL> select comp_id 2 , comp_name 3 , version 4 , status 5 from dba_registry; COMP_ID COMP_NAME VERSION STATUS -------- ----------------------------------- ------------- ------ APEX Oracle Application Express 4.0.2.00.09 VALID XDB Oracle XML Database 11.2.0.2.0 VALID CONTEXT Oracle Text 11.2.0.2.0 VALID CATALOG Oracle Database Catalog Views 11.2.0.2.0 VALID CATPROC Oracle Database Packages and Types 11.2.0.2.0 VALID
When JVM is installed, we would see the component ids JAVAVM and CATJAVA in the list:
COMP_ID COMP_NAME VERSION STATUS -------- ----------------------------------- ------------- ------ JAVAVM JServer JAVA Virtual Machine 11.2.0.2.0 VALID CATJAVA Oracle Database Java Packages 11.2.0.2.0 VALID
No JAVA component ids in DBA_REGISTRY, which means no JVM in this Oracle instance.
Method 3: Check V$OPTION
V$OPTION displays Oracle database options and features. Check if the value of parameter ‘Java’ is TRUE or FALSE (when Java is available, the value would be TRUE):
SQL> select * from v$option 2 where parameter = 'Java'; PARAMETER VALUE ---------------------------------------- ------- Java FALSE
‘Java’ — so V$OPTION tells us — is FALSE.
How to install JVM
After confirming that JVM is missing/misconfigured in your Oracle database, you would want to install/reload it. [Oracle XE users — see the next section]
Refer to Oracle Support Note (Doc ID 1112983.1) for steps to reload the JVM in Oracle 11.2.0.x. The support note links to similar notes for other Oracle versions too.
If JVM is entirely missing from the database (i.e. no previous installation exists), these simpler guide may help:
No JVM in Oracle Expess Edition (XE)!
Oracle XE — the entry-level edition of Oracle — does not have Java support, so you cannot install JVM in Oracle XE. Take a look at Oracle Express Edition Licensing Information for details.
If you must use Java in Oracle, switching to a higher database edition is called for.
Summary
This article provides three methods to check if JVM is installed in Oracle or not. These are through lookups on:
- ALL_REGISTRY_BANNERS
- DBA_REGISTRY
- V$OPTION
Also read: how to store and call Java methods in Oracle.