• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exec java  RSS feed

 
Gizzmo Zeuzere
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I want to run java program in a java program. When i do this :
Process p = Runtime.getRuntime().exec(jav);
try{
p.waitFor();}
catch(InterruptedException ire){}
InputStream is = p.getErrorStream();
BufferedReader br =new BufferedReader(new InputStreamReader(is));
while(br.readLine() != null)
{ agl.console.append(br.readLine()); }
}
catch(IOException ioe){}
where jav="java prog"
It works under windows but not under linux, i don't understand. Can anybody helps me ?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that it is a path or current directory issue. Are you running this code from a server or from the command line ?
Can you try putting the full path to the "java" executable in your command string (eg. "/usr/local/java/bin/java prog") ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!