Press "Enter" to skip to content

How to Load JAR File in Oracle Database?

In Oracle Database, use loadjava utility to load JAR file. The loadjava utility creates schema objects in Oracle database and then load JAR file contents into it. So, you must have CREATE TABLE AND CREATE PROCEDURE privileges to use loadjava utility. Also, you need some permissions on Java programs to execute it. In this tutorial, I am explaining how to load JAR file in Oracle Database.

Follow These Steps to Load JAR file in Oracle Database

  1. If you are loading JAR files the first time to execute Java programs, then run the following commands in Oracle by connecting with SYS credentials, else you can skip this step. Run the statements as shown below:

Note: Replace the USERNAME with the username to which you want to grant the permission.

sqlplus sys/[email protected] as sysdba

call dbms_java.grant_permission('USERNAME', 'java.util.PropertyPermission','*', 'read,write');
execute dbms_java.grant_permission('USERNAME','java.util.PropertyPermission','*','read');
execute dbms_java.grant_permission( 'USERNAME', 'SYS:java.lang.RuntimePermission', 'getClassLoader', ' ' );
execute dbms_java.grant_permission( 'USERNAME', 'SYS:oracle.aurora.security.JServerPermission', 'Verifier', ' ' );
execute dbms_java.grant_permission( 'USERNAME', 'SYS:java.lang.RuntimePermission', 'accessClassInPackage.sun.util.calendar', ' ' ) ; 
execute dbms_java.grant_permission( 'USERNAME', 'java.net.SocketPermission', '*', 'connect,resolve' );
execute dbms_java.grant_permission( 'USERNAME', 'SYS:java.lang.RuntimePermission', 'createClassLoader', ' ');
  1. Now open the command prompt and change to the directory where your JAR files exist. For example, if you extracted JAR files at C:\javajars, then change the current folder to C:\javajars. Then run the loadjava command as following:

Note: Change the USERNAME, PASSWORD, and DBNAME with your user and database details. Also, change the activation.jar with your Jar file name.

loadjava -user USERNAME/[email protected] -resolve -synonym activation.jar

If the above command execution completed without giving any message that means everything is ok. Your JAR files are loaded successfully.

See also: