F
freesoft_2000
Hi everyone,
I have a rather newbie question so please bear with me
for a while.
You see i am trying to run a jar file programmatically
and i am not quite sure how to do it. You see i use windows and i always
double-click on it to run but now i have a requirement to run a jar file
programmatically.
This is what i have so far
import java.awt.*;
import java.awt.event.*;
public class RunningApplications
{
public void runapplications ()
{
try
{
String str1 = "C:/j2sdk1.4.2_04/bin/java";
String str2 = (".;" + "C:/");
String str3 = "JButtons.jar";
String[] str4 ={
str1, "-jar","-cp", str2, str3
}
;
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(str4);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
RunningApplications a = new RunningApplications();
a.runapplications();
}
}
My java.exe is as located as shown by the value of str1 and my
jar file is located at "C:\JButtons.jar". Basically all i need is a way to
run that jar file and seeting the classpath programmatically by using the
Runtime class.
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West
I have a rather newbie question so please bear with me
for a while.
You see i am trying to run a jar file programmatically
and i am not quite sure how to do it. You see i use windows and i always
double-click on it to run but now i have a requirement to run a jar file
programmatically.
This is what i have so far
import java.awt.*;
import java.awt.event.*;
public class RunningApplications
{
public void runapplications ()
{
try
{
String str1 = "C:/j2sdk1.4.2_04/bin/java";
String str2 = (".;" + "C:/");
String str3 = "JButtons.jar";
String[] str4 ={
str1, "-jar","-cp", str2, str3
}
;
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(str4);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
RunningApplications a = new RunningApplications();
a.runapplications();
}
}
My java.exe is as located as shown by the value of str1 and my
jar file is located at "C:\JButtons.jar". Basically all i need is a way to
run that jar file and seeting the classpath programmatically by using the
Runtime class.
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West