Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java programs & Windows batch files" Watch "java programs & Windows batch files" New topic
Author

java programs & Windows batch files

Renu, Vairagade
Greenhorn

Joined: Feb 02, 2001
Posts: 21
Hello,
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?
reporting.bat
---------------------------------------------------
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.
-Mirko
Renu, Vairagade
Greenhorn

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(webtrends.com), 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
Sheriff

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: http://aspose.com/file-tools
 
subject: java programs & Windows batch files
 
Similar Threads
java program & Windows batch files
java program that can run a .class file in msdos, is this possible?
Not able to run java
Running a Java Program from Command Prompt
java program & Windows batch files