Oracle loadjava Loading and Dropping Java Objects
Call for Oracle support & training (800) 766-1884
Free Oracle Tips

Corporate Oracle Training
Custom Oracle Training
Oracle New Features Training
Advanced Oracle DBA Classes
Oracle Tuning Courses
Oracle Tips & Tricks
Oracle Training Links
Oracle Training Links
Oracle Training Links

We are top for USA Oracle Training Clients


Free Oracle Tips


Free Oracle App Server Tips


Oracle support

Oracle training

Oracle tuning


Remote Oracle

Custom Oracle Training

Donald K. Burleson

Oracle Utilities Tips

The SQLJ Utility

Loading and Dropping Java Objects

The loadjava utility (Oracle 8.1.5 and up) loads Java source and class files into the database. When class files are created in a conventional manner, outside the database, loadjava is used to get them into the database.

loadjava requires two database privileges to load java objects into your own schema: CREATE PROCEDURE and CREATE TABLE. To load Java objects into a schema other than the currently connected user, CREATE ANY PROCEDURE and CREATE ANY TABLE privileges are required.

This example will use a simple Java program that will be compiled outside of Oracle and then loaded into the database.

public class SimpleJava {

public void main(String[] args) {
System.out.println("Here we are");

From DOS or UNIX :


C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.class

The class file is now loaded into the database and visible from the dba_objects view with an object type of JAVA CLASS.

From SQL*Plus, create the PL/SQL wrapper to invoke the newly loaded Java class:
SQL> create or replace procedure call_simplejava
2 as language java
3 name 'SimpleJava.showMessage()';
4 /

Execute the code from SQL*Plus:

SQL> set serveroutput on;
SQL> call dbms_java.set_output(50);

Call completed.

SQL> execute call_simplejava;
Here we are

PL/SQL procedure successfully completed.

In this example, the Java class file was loaded into the database. The Java source file can also be loaded. But, both the source and class files cannot be loaded at the same time.

C:\oracle9i\bin>loadjava -user scott/tiger

If loading many Java class files at one time, it is advisable to put them in a JAR file and load them into the database at one time, since the loadjava program will also load JAR files. A JAR file is a group of Java class files lumped into one file, a format similar to TAR (on UNIX ) and WinZip (on Windows). The contents of a JAR file can be viewed using these popular utilities. Java developers prefer to distribute a few JAR files rather than many individual Java class files.

loadjava provides many command line options for the Java developer. The complete list can be viewed by typing loadjava at the command line.

Just as loadjava loads the database with our Java files or classes, the dropjava utility deletes them. In the example below, the class file that was loaded with loadjava is removed. And just like loadjava, it will drop Java source, Java classes, or JAR files.

C:\oracle9i\bin>dropjava -u scott/tiger SimpleJava.class

Alternatively, instead of using the command line utility, you can call a package that will do the same thing:

SQL> call dbms_java.dropjava('... options...');

Dropjava can be used to delete Java objects from the database. These Java objects may have been loaded into the database through the loadjava utility. The next utility also loads code into the database; only instead of Java, it loads a PL/SQL Server Page (PSP).

To learn more about these techniques, see the book "Advanced Oracle Utilities: The Definitive Reference". 

You can buy it directly from the publisher and get instant access to the code depot of utilities scripts.




Oracle performance tuning book



Oracle performance tuning software

Oracle performance tuning software
Oracle performance Tuning 10g reference poster
Oracle training in Linux commands
Oracle training Excel
email BC:

Copyright © 1996 -  2014 by Burleson Inc. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.