Search code examples
javawindowsbatch-filebackground-process

Windows batch file : How to redirect console logs of a background process to 'NUL'


I have created a batch file which calls a java process in background. All I want is to redirect the logs of the java process to a 'NUL' output so that the background terminal does not contain any output.

Contents of my batch file:

@echo off
START /MIN java -jar ./myapp.jar >null 2>&1

However when I run the batch, I minimized windows terminal opens up which still displays all the logs.

I require to disable this logging, without changing the app.jar


Solution

  • If you just want to ignore any console input and output, execute your Java program on a Windows platform and need to prevent the opening of a console window, then use the javaw executable instead of java.