• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22563
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...".
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
reply
    Bookmark Topic Watch Topic
  • New Topic