File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes spawning cmd scripts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "spawning cmd scripts" Watch "spawning cmd scripts" New topic
Author

spawning cmd scripts

Aaron Ehrensberger
Greenhorn

Joined: Jun 22, 2004
Posts: 7
I'm spawning a .cmd script from within my main java app. Inside that script, it's setting up some values, then trying to spawn another java program. I don't believe that the 2nd java program is executing or returning to the calling script and then the 1st script hangs.

The code to call the initial script....

Process p = Runtime.getRuntime().exec(updateFile);

// Create threads to read the output and error streams.
OutputWriter errorWriter= new OutputWriter(p.getErrorStream(), "ERROR");
OutputWriter outputWriter = new OutputWriter(p.getInputStream(), "OUTPUT");
// Start the threads.
errorWriter.start();
outputWriter.start();

result = p.waitFor();


This code calls a script that contains a line ...


cd /D %LEADERBOARD_HOME%\server\leaderboard\deploy\Leaderboard.ear

java -classpath %classpath% com.smg.common.utils.MSSQLDSFileEditor %LEADERBOARD_HOME%\server\leaderboard\deploy %RegValue2% %RegValue3% %RegValue4%


Calling this script directly from a command prompt works fine, so I know that the script is working, but somewhere when java calls the script to call java, I'm missing something.

Is this possible? What am I missing?

Thanks,
Aaron
[ October 25, 2004: Message edited by: Aaron Ehrensberger ]
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Perhaps your script doesn't know the variables, like '%LEADERBOARD_HOME%'. ?
They aren't 'inherited' from the environment automatically.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spawning cmd scripts
 
Similar Threads
UnsupportedEncodingException
Running java program from another java program
testing locks
problem calling isql or osql from java
new command window