Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Open a command prompt using Runtime.getRuntime().exec() and run a jar file  RSS feed

 
Aji Sree
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anybody give a hint how I can open a command prompt (in Linux as well as windows) using Runtime.getRuntime().exec() method
and run a jar file?

The idea is to run another java application from my java application and view the console debugs in the opened command prompt.

I was able to open command prompt in ubuntu linux with this.



but how should I supply the commands to run the jar file?


tried like this .



But it just opened the command prompt. thats all.

Please help..

thanks in advance
Ajith
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try typing "gnome-terminal -h" or "gnome-terminal --help" in your terminal. You may need another parameter. For instance, in Windows, it's not "cmd java ..." but "cmd /C java ...".
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aji Sree wrote:H
The idea is to run another java application from my java application and view the console debugs in the opened command prompt.


You would do better to read the Process stdout and stderr and write them to your application stdout and stderr. That way you avoid two of the problems highlighted in the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!