Bookmark Topic Watch Topic
  • New Topic

problem running .BAT file from the Java app

 
Manoj Gundawar
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
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).
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic