batch output redirection

bignose956

Senior Member
I am totally inexperienced with batch (.bat) files, so please bear with me...

I have a Java program that I run with cmd, and I want to record the console output to a text file. In other Java programs I've created, I used jars (.jar) to run the program, thus I didn't need cmd, and I could use Java methods to record the output. This program is the exception.

Could anyone please give me sample batch code that would record the following batch file console output to a text file?
Code:
@echo off
java -Xms512M -Xmx1G -XX:+UseConcMarkSweepGC -jar craftbukkit-1.8.8.jar
pause
 

Neemobeer

Application and Cloud Security Engineer
Staff member
All you need to add is one of the following to the end of the java -Xms512... command

This creates a new files and overrides existing data in the file
> outputfilepath/name

This creates a new file or appends data if the file exists
>> outputfilepath/name

This creates a new file or appends ERROR DATA ONLY
2> outputfilepath/name
 

bignose956

Senior Member
All you need to add is one of the following to the end of the java -Xms512... command

This creates a new files and overrides existing data in the file
> outputfilepath/name

This creates a new file or appends data if the file exists
>> outputfilepath/name

This creates a new file or appends ERROR DATA ONLY
2> outputfilepath/name
This is almost perfect! My only other question is, do they have a method that will write to the output file during the execution of the batch, rather than after? Because with this one, it only writes to the file after the command prompt or batch file is closed or terminated.
 
Top