• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to execute a jar file at run time  RSS feed

 
Maheswaran Devaraj
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!