• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to execute a jar file at run time

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want to execute a jar file at runtime. I have used the following code. But it throws exception, Can any one tell me how to do that.
mycode is
--------------
{code}
import java.io.File;

public class FileExecution {

public static void main(String args[]){

try {


Runtime runtime = Runtime.getRuntime();
runtime.exec("C:/Documents and Settings/pmr/Desktop/swingcallbackdemoapp.jnlp");



} catch (Exception e) {
e.printStackTrace();
}


}
}

{code}

Regards,
Mahes
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look for the ProcessBuilder class, and also google for "when Runtime.exec() won't". Michael Daconta's classic article explains why you are getting Exceptions.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic