Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

java programs & Windows batch files  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!