import java.util.*;
public class GoodWindowsExec
{
public static void main(String args[])
{
Vector v = new Vector();
v.add("D:\\file1.java");
v.add("D:\\file2.java");
v.add("D:\\file3.java");
//v.add("D:\\file1.java&D:\\file2.java");
for(int i=0;i<v.size();i++)
{
try
{
String path = v.elementAt(i).toString();
String osName = System.getProperty("os.name" );
String[] cmd = new String[3];
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = path;
Runtime rt = Runtime.getRuntime();
System.out.println("Executing : " + cmd[0] + " "
+ cmd[1]+ " " + cmd[2]);
Process proc = rt.exec(cmd);
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}
}
I tried to execute above program.
The default editor for java files is set to TextPad.
But when i run the program then it launched 3 different instances of textpad.
If i used '&' seperated filenames(Example : pah ="D:\\file1.java&D:\\file2.java") then it opens the next file when i close the first file.
What i want to do is :
1. Only one instance of textpad should open all the files.
2. If textPad is already lauched then on executing the program new instance of textpad should not be lauched .The files should be opened in the existing instance.
Any help in this would be of great help to me.
Thanks & Regards,
Veda