How to decouple a Java application from the console during runtime

Viewed 79

I have a Java Swing application that is launched from Windows command line. This application displays a Swing window and exits when the user closes the window.

What I want is to print to Windows console a couple of messages using System.out then return from Windows console so I can close it with the application still running in background.

When running the application with java -jar ... I cannot close the Windows console without closing the application, while javaw -jar ... decouples the application from the console and no message is printed.

Is there a solution to decouple the Java application from the console during runtime?

2 Answers

Why dont you try adding "&" at the end of the command. This will move the application running at the background and still the logs would be printed.

Eg. assume your jar name is abc.jar

try

java -jar abc.jar &
Related