UTEK
asked on
How to excute multiple DOS command simultaneously?
I have a signed applet. It has couple links to the documents on user's local machine. When user clicks on a link, it creates a new thread and uses DOS "start" command to open the document. The run method of the thread is something like this:
public void run()
{
//Now call up the application to view doc
try
{
//Get Windows information
System.out.println(System. getPropert y("os.name "));
System.out.println(System. getPropert y("os.arch "));
System.out.println(System. getPropert y("os.vers ion"));
//This is NT command
Runtime.getRuntime().exec( "cmd /C \"start /wait
"+defdir+"\"").waitFor();
System.out.println("Finish ing editing - "+defdir);
}
catch (Exception e)
{
System.out.println(e.getCl ass.getNam e());
}
}
When I opened the first document, it was fine. The document did stay on the screen. When I opened the 2nd document while the 1st one was still up, it did launch the 2nd document in WORD BUT the 2nd thread immediately executes ==> System.out.println("Finish ing editing - "+defdir); without waiting the close down of the 2nd document. How come?
Is it because each applet has only one runtime env and it can only execute one dos command at a time? Is there any work around? Or any alternative?
My goal is to launch multiple applications(associated with the files) on the local machine to edit the documents. Once the user finishes editing a doc, the applet determines if the document has been modified. If so, it saves it back to the server.
public void run()
{
//Now call up the application to view doc
try
{
//Get Windows information
System.out.println(System.
System.out.println(System.
System.out.println(System.
//This is NT command
Runtime.getRuntime().exec(
"+defdir+"\"").waitFor();
System.out.println("Finish
}
catch (Exception e)
{
System.out.println(e.getCl
}
}
When I opened the first document, it was fine. The document did stay on the screen. When I opened the 2nd document while the 1st one was still up, it did launch the 2nd document in WORD BUT the 2nd thread immediately executes ==> System.out.println("Finish
Is it because each applet has only one runtime env and it can only execute one dos command at a time? Is there any work around? Or any alternative?
My goal is to launch multiple applications(associated with the files) on the local machine to edit the documents. Once the user finishes editing a doc, the applet determines if the document has been modified. If so, it saves it back to the server.
What about using OLE automation ? It's nicer don't you think so ?
Are you sure, you are creating a new thread, not using the same one ?
If you make
WordCreator x = new WordCreator("a word document");
and on button press
x = new WordCreator("another word document");
the first one is destroyed.
It's this the problem ?
If you make
WordCreator x = new WordCreator("a word document");
and on button press
x = new WordCreator("another word document");
the first one is destroyed.
It's this the problem ?
ASKER
objects:
Yes, Windows opens a new instance of Word, two seperate Word windows.
mariuso:
We would like to deploy our applet to both IE and netscape (as many Java enable browser as possible) across Windows, Mac , Unix and Linux. Netscape and other platforms do not support OLE automation, do they? On the other hand, how does Active X control work with Java applet?
Yes, they are running in different thread.
I have a Vector object to store the reference, so even x is assigned to a new reference, the old thread is not destroyed.
Yes, Windows opens a new instance of Word, two seperate Word windows.
mariuso:
We would like to deploy our applet to both IE and netscape (as many Java enable browser as possible) across Windows, Mac , Unix and Linux. Netscape and other platforms do not support OLE automation, do they? On the other hand, how does Active X control work with Java applet?
Yes, they are running in different thread.
I have a Vector object to store the reference, so even x is assigned to a new reference, the old thread is not destroyed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
objects, thanks for pointing it out. It first starts with 2 Word processes and then finially they merge into one process and kill my 2nd thread....SHOOT.
Thanks for the points :)
Does the second doc get opened in a new instance of Word or the same.
Not sure of a workaround, it's really a Windows specific question. You could fire up the application directly but that'll introduce lots of other problems.