Getting Ready to Use Java in Oracle

Before you can call Java methods from within your PL/SQL programs you will need to do the following:

  • Install a Java Development Kit ( JDK™). (Check the Oracle documentation for the latest information about version support.)

  • Build your Java classes and code elements, and then compile them into .class and .jar files.

  • Set privileges on your Oracle schema.

Installing Java

You will need to install a Java Development Kit ( JDK) 1.1.5 or above. You can do this by downloading a JDK from the Javasoft web site; Oracle also provides a JDK starting with the Oracle8i release. Here is the Javasoft URL:

http://www.javasoft.com/products/index.html

Make sure to set the environmental variableCLASSPATH so that the Java compiler (javac) can locate any references to your classes—and to the Oracle classes. Visit the following URL to get more information about CLASSPATH and general documentation on the Java language:

http://java.sun.com

Building and Compiling Your Java Code

Many PL/SQL developers (myself included) have never worked with an object-oriented language of any kind, so getting up to speed on Java can be a bit of a challenge. In the short time in which I have studied and used Java, I have come to these conclusions:

  • It doesn’t take long to get a handle on the syntax needed to build simple classes in Java.

  • It’s not at all difficult to start leveraging Java inside PL/SQL.

  • Writing real object-oriented applications using Java requires significant rethinking ...

Get Oracle PL/SQL Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.