views:

108

answers:

4

Hi all,

I'm doing a build script for a Java application to run inside the Oracle JVM. In order to import the 50-odd classes, it appears I need to bring them in in order so any dependencies are present before compilation.

For each class, I'm running 'create or replace and compile java source {className} as {classPath}' for each file. Doing this gives me a compilation error, as the required class(es) are not imported.

How can I generate a list of the classes, in dependency order, that is, as you go down the list, the class's dependencies are listed above. I would prefer to do this as an ant task.

Also if you have a better idea of how to get these classes imported, I'd love to hear your ideas.

Thanks

A: 

In order to import the 50-odd classes, it appears I need to bring them in in order so any dependencies are present before compilation.

I have never had to do such a thing simply to compile Java.

This is what Ant was born for. I'd recommend just doing this with Ant. Set the <classpath> and you'll have no trouble.

duffymo
You're right, in the world of Java or Ant, but this is loading Java classes into Oracle via SQLPlus. I'm using Ant to build the deployent artefact and dynamically make the SQL to load the class (ie create...)
Glenn2041
A: 

Brute force method: put the 50 CREATEs in a batch file and execute it until no errors are found. Create the loop in a shell script. Of course it will never end if there are errors in the sources, but I'm assuming they are ok.

Lluis Martinez
Glenn2041
A: 

Compile the classes in the filesystem using the ant core task javac. Use the optional task depend if more rigorous dependency checking is needed. Use the loadjava tool to load the .class and .java files into the database in arbitrary order.

trashgod
Looking at `dbms_java.loadjava()` currently.
Glenn2041
+1  A: 

I can't imagine why you'd need to do this, but if you really need to do this, I wonder if hacking a little classloader that prints out each class as it loads and load your app from there would give you a dependency graph?

Steve B.
It should be noted that dependencies in Java may be cyclic. There isn't really an order which would work in this case.
Adam Hawkes