This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes java programs & Windows batch files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java programs & Windows batch files" Watch "java programs & Windows batch files" New topic

java programs & Windows batch files

Renu, Vairagade

Joined: Feb 02, 2001
Posts: 21
I want to write a Window .bat file (batch file) that executes a java program. I've written one batch file(see below), but it does not execute java program. What's wrong?
copy C:\Report_Input.TXT C:\back_up_reports
java TransformFile1
copy Output_file.TXT C:\back_up_reports

V Renu

V Renu
Mirko Froehlich
Ranch Hand

Joined: Aug 21, 2000
Posts: 114
There could be many reasons. Do you get any error messages?
Is the "java" executable in your path, i.e. does your system find it when you open a command prompt and type in "java"?
What happens when you start the Java application from the command line without using a batch file? It should either work or give you an error message. Maybe you aren't calling it from the right directory, the Java class might be packaged but you don't specify the package on the command line, some required packages might be missing from the classpath, etc. Post your error message and I'll try to help you.
Renu, Vairagade

Joined: Feb 02, 2001
Posts: 21
My batch file works finely, when executed from command line, executes the java program properly, gives no error message. But that's doesn't solve my problem. Actually, I am using an application called WebTrends log Analyzer(, which generates certain statical reports on websites. It gives one option called Post-processing, which allows to excute a specified .exe or .bat file just after report-generation. I am using it & want the java program TransformFile1 to be executed through the .bat file. But that doesn't happen with WebTrends Log Analyzer.
V Renu
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
The BAT file should change directory to the location of th class file. Even if the bat is in the same diectory, if you double click on it from explorer, the working directory is the first directory that your cmd shell opens in.
The other thing you could do is place the directory (or jar file) where that class exists in your classpath.
Hope This Helps
Carl Trusiak

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
I agree. Here's the link:
subject: java programs & Windows batch files
It's not a secret anymore!