milesma
milesma

Reputation: 328

How to compile Java files silently unless there are errors?

I have following commands in a shell.cmd file, and it runs correctly.

"C:\Program Files\Java\jdk1.7.0_51\bin\javac.exe" -verbose -g -cp "SOMETHING" -d "../classes" *.java

cd ..

if not exist dist mkdir dist

"C:\Program Files\Java\jdk1.7.0_51\bin\jar.exe" cf "./dist/my.jar" -C ./classes .

But, I get a lot of output to the console during compilation to .class and then when creating .jar files.

How can I disable the messages? Without disabling error messages.

Upvotes: 1

Views: 242

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201447

You can add @echo off, and remove the -verbose flag. And, I'd add the Java bin folder to the path. Something like,

@echo off
set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_51"
set "PATH=%PATH%;%JAVA_HOME%\bin"
javac.exe -g -cp "SOMETHING" -d "../classes" *.java

cd ..

if not exist dist mkdir dist

jar.exe cf "./dist/my.jar" -C ./classes .

Upvotes: 1

Related Questions