将 Java 控制台应用程序作为守护进程运行(后台)

2022-01-16 00:00:00 jvm java jvm-arguments

我开发了一个 Java 控制台应用程序,当启动时,打开一个控制台窗口并保持在前台,我想在后台启动该应用程序.

I've developed a Java console application that when start, open a console window and remain in foreground, i want to start that application in background .

现在我通过这个命令行启动应用程序:

Now i launch the application by this command line :

java -jar myapp.jar

有没有办法实现这种行为?更改命令行参数就足够了,或者我需要对我的代码进行一些更改?

Is there a way to achieve this behaviour ? It's enough change the command line parameter or i need to do some change on my code ?

推荐答案

答案取决于操作系统.

*nix: <your command> &
Windows: (opens a new console): start <your command>
Windows: (doesn't open a new console): start /b <your command>

相关文章