Ok So I Have two programs, One program to write to a new document a list of variable values I have captured. And another to do something similar with another set of values.
I realise that I can simply call two seperate programs within the command prompt window but is there a way by writing a method and stipulating a path (like a css regeference to html) where I can call the second program.
I'd rather do this than add the class from one program to the other and then fiddle around with it.
This may sound silly to some but is it possible?
You can load the class and call its static main method. If you know the class at compile time it's simply a matter of calling If you don't know the class at compile time you can use reflection to execute the main method:
Note that this may not really be what you want to do.
Depending on how things are written and used it might be just as easy to pipe the output of one program (instead of writing it directly to a file as you do now) into the input of another. This is *much* more versatile than writing to a file, because you can still get the file output by redirecting to a file. So instead of:
$ foo outputFileName
$ foo > outputFileName
This lets you do things like:
$ foo | bar > outputModifiedByBarFileName
I don't see any advantage of calling one program from within another: you've already introduced a dependency, so you might as well do it right and just have its classes on the classpath and do it all using normal Java, with the caveat that your code as it stands is not really set up for any sort of re-use or extensibility.
subject: Can I Call A Seperate Program Inside Another?