简体   繁体   English

如何在PC启动时自动启动Java应用程序?

[英]How to make a Java app automatically start when PC starts?

I'm developing a scheduling app, it reminds user of things to do during a day, it checks every minute to see if time is up, and if it is it will open an alert window to remind the user. 我正在开发一个调度应用程序,它提醒用户一天中要做的事情,它会检查每一分钟是否时间到了,如果是,它会打开一个警告窗口来提醒用户。 Although it's written in Java, I'm targeting Windows users for this app. 虽然它是用Java编写的,但我的目标是Windows用户。 It needs to run as soon as users' PCs are turned on, so my question is: How to make a Java app automatically start when a PC is turned on in a Windows system? 它需要在用户的PC打开后立即运行,所以我的问题是:如何在Windows系统中打开PC时自动启动Java应用程序?

I know I can go through a few steps manually to add the app to start-up apps list, but not every user is familiar with the steps, so I wonder if it can do this through my Java program, and if so is there any sample code? 我知道我可以手动执行几个步骤将应用程序添加到启动应用程序列表中,但不是每个用户都熟悉这些步骤,所以我想知道它是否可以通过我的Java程序执行此操作,如果有,那么是否有任何示例代码?

Use Java Service Wrapper . 使用Java Service Wrapper Set wrapper.ntservice.starttype=DEMAND_START in wrapper configuration . 包装器配置中设置wrapper.ntservice.starttype=DEMAND_START

create a .bat file 创建一个.bat文件

@javaw -jar path/to/jar/Name.jar arguments

drop this in you startup directory 将它放在启动目录中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM