I'm wondering if i can build a JAVA program 2 within JAVA a program 1, compile the program 2 in the program 1 and then run program 2 from the program 1?
I need to do this because the PipedInput/OutputStream processes need to know which, in this case Oracle table, is being used, to verify both ends of the pipe, right up front!
I've tried every combination of things, and the only one that works is when everything the program needs is known by the system right up front!
And because i have over 300 potential files to process, for me to create a unique program for every file, would result in having to create over 300x4 unique programs!
Right now i am extracting the file requested, passing the parms to a .ksh shell, the .ksh shell assembles the pieces of the program, including table name seleted, compiles the program and then runs the program!
So now i'd like to see if i can put this process into a java program as some of our users are not using UNIX!
Reflection won't really help you compile and run a Java program; it only can be used to inspect and access existing compiled Java classes. It will be necessary to use reflection (in the form of the Class.forName() and Class.newInstance() methods) to load the code after you've compiled it.
You can invoke Sun's Java compiler like this, or you can use the Runtime.exec() method to run it via the command-line interface.
Although they've always discouraged it in the past, I think there may even be an official Sun document somewhere about invoking the newest version of the compiler from code -- I just can't remember where I saw it.
Originally posted by bob connolly: I need to do this because the PipedInput/OutputStream processes need to know which, in this case Oracle table, is being used, to verify both ends of the pipe, right up front!
I don't fully understand what you are getting at here, but I strongly suspect that there will be a *much* simpler approach to solve this problem. Care to elaborate?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Mar 10, 2004
Basically, i was trying to get the following PipedInput/OutputStream program to work, by passing an oracle table name into the program, but for some reason, the pipes don't want to connnect when the table_name is passed into the program, but if the name is "hard coded" in the program it works fine!
So what i've done so far, is build the program via UNIX scripts, ie, when a user selects a file from an online screen, the script concatenates the program pieces together ie, header_code + oracle_table_name + trailer_code, compiles it and runs it!
But now i need to package up the process so that it runs via JAVA only components as 1 of our users isn't using UNIX, so i've been able to put most of processes into 2 JAVA programs, except for this one, which extracts XML from an oracle table and validates it using a SAX validator and instead of writing the XML to an external file, it buffers the XML directly into the validation routine, eliminating a huge external XML file!
This feature was "supposed" to be available in 10g!
Here is the program if you might have any ideas about why the Piped files don't want to connect unless the table_name is hard coded, see <<<<<<<<<<< in the code
Is this whole effort to change the table name? Can you just get table names from parameters or a file?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jul 11, 2001
Originally posted by bob connolly: Basically, i was trying to get the following PipedInput/OutputStream program to work, by passing an oracle table name into the program, but for some reason, the pipes don't want to connnect when the table_name is passed into the program, but if the name is "hard coded" in the program it works fine!
Can you show us how you tried to pass the table_name into the program? I'm convinced that we should be able to get it work.
Joined: Mar 10, 2004
Well, actually, i am passing the table name into the program in:
but if i didn't have that table name hard coded initially in this line of code:
public static final String IN_TABLE=new String("fn_ll_lossmit"); <<<<<<<
, the pipes don't seem to want to make the connections, must have tested this at least 10 times!
But i will re-test it again this morning just to be triply sure!
Joined: Mar 10, 2004
Thanks for the prompt to go back and look at this from the top! as it seems to be working fine by passing the table_name in, great news! and i'm now trying to figure out what got me on this track to begin with!
So appreciate everyone's assistance on this and i quess the moral of this distraction is, the only way to be an optimist in this business is to be a pessimist, when the analyst, programmer and tester are one in the same?
But on the bright side, i now know how to build, compile and run a JAVA program from within another JAVA program, very nice! and i wrote a Groovy script to do a similar thing!
Have a great week all!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Can i build and compile a JAVA pgm in another JAVA program?