File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RUNNING AN EXE THROUGH A JAVA PGM

 
Neela Sathesh
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
I had worked with Runtime Command in java,using that i could able to open only some general programs like turboc,notepad,winamp etc.How to run other EXE file ,for eg i have created a c program ds.exe and how to execute it from Java.Please provide me the help as soon as possible.
Thank you
 
Ram Mohan
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure the program is in your path....or add the program's path to your environment variable....if all this fails try giving the full path of the program like c:\myfolder\ds.exe
 
Neela Sathesh
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friend,
thank u but, we have tried with this(full path). i found only tc, notepad,winamp can be executed with it. all other .exe are not running.give me some other suggestions...
thank u, bye.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a Servlet question, moving this thread to Java in General (beginner).
Dave
 
Ram Mohan
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can u post the snippet of code that actually calls ur .exe program...maybe there is some error there
 
Neela Sathesh
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
 
Neela Sathesh
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
{
RuntTime r=RunTime.getRunTime();
Process p=r.execute("c:/turboc3/bin/sat.exe");
}
catch(Exception e)
{
}
The above pgm gives the path of exe file in c.If I give inplace of sat.exe
as "notepad"or"winamp" it is working.Please can u clear my dbt
 
Ram Mohan
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
don't really know what's wrong with your code...i was not able to even compile ur code (where exactly is this RunTime interface???)...but the following code does work
try
{
Runtime r=Runtime.getRuntime();
Process p=r.exec("c:/winnt/hh.exe");
}
catch(Exception e){}
}
do let me know if it helped
 
Martin Valjavec
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime.exec() has a few pitfalls. Have a look at this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic