aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes problem running .BAT file from the Java app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply locked New topic
Author

problem running .BAT file from the Java app

Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
Hi,
I need to run .BAT file from Java application.
here is the code I am following:
class test....{
try{
Runtime.getRuntime().exec("Jtier.BAT");
}catch..
There are three commands to execute in the .Bat file
SET PATH=%PATH%;C:\j2sdk1.4.0\bin;
SET CLASSPATH=.;C:\j2sdk1.4.0\classes;C:\j2sdk1.4.0;C:\mq.jar;
java Jtier

But it dosent work. It dosent execute hte JTier application, when I run test java program.
But when I change the code as:
class test....{
try..
Runtime.getRuntime().exec("java Jtier");
}catch..
It works.
Please help me to understand how it works. Does my .bat file should have only one command to execute? Can this not execute mulitple commands?
Please let me know.
Thanks,
Manoj


Manoj<br />SCJP, SCJD, SCWCD, IBM WSAD.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Does this have something to do with the Developer Certification exam? I think you probably want to post this in another forum, such as Java in General (Intermediate). If you're using a BAT file as part of your developer exam, your code is very unlikely to run on other machines (esp non-Wndows machines).


"I'm not back." - Bill Harding, Twister
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11422
    
  85

Since Manoj opened the same question in JiG (Intermediate) following Jim's comment, I have closed this thread.
Please post any comments in Manoj's other thread for this question.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem running .BAT file from the Java app