Description:
A “JAR” (Java Archive) file comprises of many Java class files and associated metadata and resources such as text, images, etc., into one file.
Loadjava utility is used to load Java source and class files into the database. Basically, it creates schema objects in Oracle database and loads contents of JAR files into it. One must have enough privileges to use loadjava utility.
Following are the set of privileges needed to use loadjava or dropjava utilities.
Utility |
Required privileges |
To perform |
loadjava |
CREATE TABLE , CREATE PROCEDURE |
To load JAR files in database schema |
loadjava |
CREATE ANY PROCEDURE, CREATE ANY TABLE |
To load into another schema |
dropjava |
DROP ANY PROCEDURE, UPDATE ANY TABLE |
To drop from another schema |
Syntax to load jar files:
Download abcd.jar files to local directory and invoke loadjava
loadjava -verbose -u testuser/testpaswd -resolve -jarsasdbobjects abcd.jar -genmissing
In the above example options -resolve compiles and resolves external references in classes and
-genmissing used to generate missing classes.
To compile the java classes either you can run “utlrp.sql” or compile it manually as,
alter java class “/abcd1234_samplejarclass” compile;
Syntax to drop jar files:
dropjava -verbose -u testuser/testpaswd abcd.jar
If you are loading jar files for the first time, grant below using dbms package,
exec dbms_java.grant_permission( ‘TESTUSER’, ‘SYS:java.io.FilePermission’,'<pathofJARfile’, ‘read’ );
exec dbms_java.loadjava(‘-u testuser/testpaswd <pathofJARfile>’);
Bottomline: Hope you may find it useful for loading the JAR file in Oracle