Get java class content from oracle database

rzysia picture rzysia · Apr 30, 2015 · Viewed 8.8k times · Source

Is it possible to get the java .class file from a database?
I mean java classes, which was loaded via loadjava tool with -r -s -v -g parameters.

How to do this?

Edit: I need it in readable form ;)

Answer

npe picture npe · Apr 30, 2015

Take a look at the DBMS_JAVA package.
With DBMS_JAVA you can export both .java and .class files, using:

  • export_source - to export .java file

    PROCEDURE export_source(name VARCHAR2, schema VARCHAR2, blob BLOB)
    PROCEDURE export_source(name VARCHAR2, blob BLOB)
    PROCEDURE export_source(name VARCHAR2, clob CLOB)
    
  • export_class - to export .class file

    PROCEDURE export_class(name VARCHAR2, schema VARCHAR2, blob BLOB)
    PROCEDURE export_class(name VARCHAR2, blob BLOB)
    

Here you can find some examples on how to use that to read the source of .java files.