将Java控制台应用程序作为守护程序运行(后台)
问题描述:
我开发了一个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 ?
答
答案是取决于操作系统。
The answer is operating system dependent.
*nix: <your command> &
Windows: (opens a new console): start <your command>
Windows: (doesn't open a new console): start /b <your command>