Automate program execution problem (Runtime.exec("java" + " Hello.java");

S

seenuvas

I want to automate the program compilation and execution.

I used Runtime.exec("javac" +" Hello.java"); for compilation the
program compiled successfully.
in the next liine i gave Runtime.exec("java" + "Hello"); This statement
dosen't performs execution.

Anybody knows tell me the solution for this problem

By
Seenu
 
J

Jeffrey Schwab

seenuvas said:
I want to automate the program compilation and execution.

I used Runtime.exec("javac" +" Hello.java"); for compilation the
program compiled successfully.
in the next liine i gave Runtime.exec("java" + "Hello"); This statement

You're missing a space. Do you have a program called javaHello?
 
O

opalpa

Want to bet?

Your refusal to post code is ... weird.

My specific guess diagnosis is A) you're not directing output from
subprocess and so you don't see an error B) the error probably talks
about class not being found.
 
F

Francesco Devittori

seenuvas said:
sorry

It is Runtime.exec("java" + " Hello");

There is one space before Hello

maybe the java executable is not found? Try with the full path
(/opt/jdk/bin/java or C:\whatever)
 
R

Roedy Green

I used Runtime.exec("javac" +" Hello.java"); for compilation the
program compiled successfully.
in the next liine i gave Runtime.exec("java" + "Hello"); This statement
dosen't performs execution.

see http://mindprod.com/javacexe.html#MAIN for a more efficient way of
invoking the Javac compiler.

you tried to exec "javaHello" which does not exist. You meant
something like this:

"java.exe Hello"

exec wants specific extensions. If you don't have them, you need to
spawn a command processor that will guess them.

see http://mindprod.com/jgloss/exec.html
 

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
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top