Help with exec

K

Kamal Zamli

Dear all

I'm trying to do compile + execute a java program from within
another java program... COnsider the following code:
.....
Process p1 = Runtime.getRuntime().exec("javac stub.java");
Process p2 = Runtime.getRuntime().exec("java stub");
.....

Using exec I manage to compile stub.java. However, I cant seem to be
able to run stub.class using exec... Any pointers ?

Thanks in advance
 
G

Gordon Beaton

COnsider the following code:
.....
Process p1 = Runtime.getRuntime().exec("javac stub.java");
Process p2 = Runtime.getRuntime().exec("java stub");
.....

Using exec I manage to compile stub.java. However, I cant seem to be
able to run stub.class using exec...

*Exactly* what happens instead?

Can you run it from a command shell, outside the program? Does it
generate any output?

/gordon
 
D

Daniel

1) You may want to wait a few seconds for it to finish compiling before
executing it.

2) You may want to specify the classpath when you execute the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top