my dog learned polymorphism
The moose likes I/O and Streams and the fly likes how to run a java program from batch file? 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 » I/O and Streams
Bookmark "how to run a java program from batch file?" Watch "how to run a java program from batch file?" New topic

how to run a java program from batch file?

Venkat Suryadevara

Joined: May 12, 2003
Posts: 9
I am unable to run a java program from a batch file that i created.
spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.what should I do to get the output to a file???

echo ^<html^>^<body^>
echo hello^<br^>
call java spiderpackage.EntryPoint
echo ^</body^>^</html^>
Lu Battist
Ranch Hand

Joined: Feb 17, 2003
Posts: 104
Try the following in your batch program:
cat htmlBegTags.txt > output.part1
java spiderpackage.EntryPoint > output.part2
cat htmlEndTags.txt > output.part3
cat output.part1 output.part2 output.part3 > myFile.html
rm output.*
where htmlBegTags.txt contain <html>...
where htmlEndTags.txt contain ...</html>
Greg Charles

Joined: Oct 01, 2001
Posts: 2956

The greater-than sign is used to redirect output to a file. It seems like you want the entire batch output in the file so, assuming the script is in mybatch.bat:
mybatch > myfile.html
should do the trick. You probably want to take "call" out of the script. That's used specifically for calling another batch file.
Maged Roshdy

Joined: Feb 08, 2003
Posts: 24
Hi all,
sorry for that i could't share you to solve this
patch problem
but i want to learn how to run java program form
a patch file could anyone help me
I agree. Here's the link:
subject: how to run a java program from batch file?
It's not a secret anymore!