Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

problem running .BAT file from the Java app

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic