Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to excute multiple DOS command simultaneously?

Posted on 2001-06-04
7
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 450 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

636 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