Solved

How to excute multiple DOS command simultaneously?

Posted on 2001-06-04
7
213 Views
Last Modified: 2011-10-03
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.getProperty("os.name"));
      System.out.println(System.getProperty("os.arch"));
      System.out.println(System.getProperty("os.version"));
     
      //This is NT command
      Runtime.getRuntime().exec("cmd /C \"start /wait
"+defdir+"\"").waitFor();
      System.out.println("Finishing editing - "+defdir);
   }
   catch (Exception e)
   {
      System.out.println(e.getClass.getName());
   }
}

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("Finishing 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.


0
Comment
Question by:UTEK
  • 3
  • 2
  • 2
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6155536
It sounds like what's happening is that when you run the command the second time Windows sees that Word is already running so the command simply passes the file to the existing process to open and then exits.
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.
0
 
LVL 2

Expert Comment

by:mariuso
ID: 6155584
What about using OLE automation ? It's nicer don't you think so ?
0
 
LVL 2

Expert Comment

by:mariuso
ID: 6155595
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 ?
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:UTEK
ID: 6156050
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.

0
 
LVL 92

Accepted Solution

by:
objects earned 150 total points
ID: 6157967
> Yes, Windows opens a new instance of Word,
> two seperate Word windows.

Two windows yes, but probably open from the one Word  process?
Have a look at the Task Manager, and see if Word is running once or twice.

Another test would be to first open word, and then run your application. Now open a document.

0
 

Author Comment

by:UTEK
ID: 6165286
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.
0
 
LVL 92

Expert Comment

by:objects
ID: 6165973
Thanks for the points :)
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 99
Maven Project: Hibernate Dependencies Conflict 10 26
xampp tool 12 51
login jsp example 24 51
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question