jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes RUNNING AN EXE THROUGH A JAVA PGM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "RUNNING AN EXE THROUGH A JAVA PGM" Watch "RUNNING AN EXE THROUGH A JAVA PGM" New topic
Author

RUNNING AN EXE THROUGH A JAVA PGM

Neela Sathesh
Ranch Hand

Joined: Jan 19, 2004
Posts: 50
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


With regards,<br />Neela.N
Ram Mohan
Ranch Hand

Joined: Jan 19, 2004
Posts: 44
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


If quitters never win, and winners never cheat, who's the idiot that said: Quit while you're ahead?
Neela Sathesh
Ranch Hand

Joined: Jan 19, 2004
Posts: 50
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

Joined: Mar 06, 2001
Posts: 13459

This is not a Servlet question, moving this thread to Java in General (beginner).
Dave
Ram Mohan
Ranch Hand

Joined: Jan 19, 2004
Posts: 44
can u post the snippet of code that actually calls ur .exe program...maybe there is some error there
Neela Sathesh
Ranch Hand

Joined: Jan 19, 2004
Posts: 50
try
Neela Sathesh
Ranch Hand

Joined: Jan 19, 2004
Posts: 50
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

Joined: Jan 19, 2004
Posts: 44
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

Joined: Jan 16, 2004
Posts: 3
Runtime.exec() has a few pitfalls. Have a look at this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RUNNING AN EXE THROUGH A JAVA PGM
 
Similar Threads
Doubt Pls Help me
Exe Generator software does not get the updated jar but gets the old jar
Create Swings application as windows setup file
java
making a exe in java