I've used javaw to running an application in the background. And it starts at windows startup.
To Achieve I've used following command in a startup-> .bat file
javaw -Xmx200m -jar C:\DataLoggingApplication\application.jar
Since it runs in the background, I'm not able see to if an application already is running. I'm using windows operating system.
How to achieve this?
在 Windows 中,您可以通过名称找到一个进程,如下所示:
tasklist | FIND "applicationName"
Hope this will help you out:
wmic process where "name like '%application.jar%'" get processid,commandline
or
wmic process where "name like '%jar%'" get processid,commandline
or
wmic process where "name like '%java%'" get processid,commandline
您可以使用Windows Powershell执行此操作以获取为运行 Java 应用程序而调用的命令和进程 ID:
String command = "powershell.exe Get-WmiObject win32_process -Filter \"name='javaw.exe' and commandline like '%filename.jar%'\"|select Pid,CommandLine"
您可以使用 jdk 中的jvisualvm
: %JAVA_HOME%/bin/jvisualvm
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.