aspose file tools*
The moose likes Threads and Synchronization and the fly likes How to run multiple processes at once, while still able to type commands to system.in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "How to run multiple processes at once, while still able to type commands to system.in" Watch "How to run multiple processes at once, while still able to type commands to system.in" New topic
Author

How to run multiple processes at once, while still able to type commands to system.in

Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
I have an assignment that involves making a command provider through system.out and system.in. Im kinda stuck because my application needs to be able to open other application (notepad, cmd, etc.) and I have accomplished that but the application needs to be able to run multiple processes at once, thats where I get stuck because when I run a application like notepad my command provider which I feed commands in order to run applications, stops responding.

Basicly here�s how I do it:


So when I type: run notepad. A notepad runs with empty txt file, but if I type: run notepad c:\myDocument.txt it opens notepad and loads the given text file.

How do I run multiple instances of f.ex notepad? I�ve tried using threads but it ain�t quite working.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Can you show us your threading code that didn't work, please?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
Here it goes:


I created an instance of Program every time the executeRun command is called.

Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
Hi,

Don't call the run method directly.

Call start() instead and it will work.

When you call run() directly it acts just like any other function. What you really need is to create a new thread and run it, and you use the start() method for that.
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
I figured it out, I was referring to the array program that wasn�t in the run() methods scope so I got NullPointerException. Thanks for the help though.
 
Don't get me started about those stupid light bulbs.
 
subject: How to run multiple processes at once, while still able to type commands to system.in
 
Similar Threads
Commandline arg question
Can't write to file
how to IO console through MyApplication?
executing linux commands through java socket
file.delete works most of the time, but fails every so often