Link to home
Start Free TrialLog in
Avatar of BocahNdeso
BocahNdeso

asked on

How to make a program to run an application

I am quite new with java, I need to make a program to run an application (eg, I want to make a program ro run MyProgram) but the program is not .exe file, it is .ksh file (eg MyProgram.ksh).

Thnks
Avatar of yongsing
yongsing

try {
   Runtime.getRuntime().exec("Program_to_run.exe");
} catch (Exception e) {}
ASKER CERTIFIED SOLUTION
Avatar of Ovi
Ovi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
try something like the following, just change the command to match your system:

public class Winamp {
 public static void main(String[] args) {
   try {
 Runtime.getRuntime().exec("/usr/bin/ksh /somewhere/winamp.ksh");
} catch (Exception e) {}
 }
}
Avatar of BocahNdeso

ASKER

if i just write :
Runtime.getRuntime().exec("C:\\Program Files\\MyProgram\\MyProgram.ksh\");
it can't execute the file. but if I call .exe file, it works...

FYI, i want to run a program that from unix based in windows ( using korn shell, a pc compatible shell )
you can't run a script like that, you instead need to pass the script as an argument to the shell for it to execute.
something like:
/usr/bin/ksh /somewhere/winamp.ksh
if i just write :
Runtime.getRuntime().exec("C:\\Program Files\\MyProgram\\MyProgram.ksh\");
it can't execute the file. but if I call .exe file, it works...

FYI, i want to run a program that from unix based in windows ( using korn shell, a pc compatible shell )
but I do not have a directory /usr/bin/ksh, because I am using windows. or is there any similarities with that in windows?
You'll probably need two parameters:

1. The path to your Win Korn shell interpreter
2. The shell script
> but I do not have a directory /usr/bin/ksh,

I realise that.
I don't know where things are on your box so I left it to you to enter the correct paths.

> or is there any similarities with that in windows

yes the path to wherever your ksh executable is.

To save yourself some time, see if you can figure out how to run the .ksh file in a command prompt first.  Then whatever works there put inside the Runtime.exec