windows 如何让 Java 应用程序在 PC 启动时自动启动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4565639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a Java app automatically start when PC starts?
提问by Frank
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. 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?
我正在开发一个日程安排应用程序,它会提醒用户一天中要做的事情,它每分钟检查一次,看看时间是否到了,如果时间到了,它会打开一个警报窗口来提醒用户。尽管它是用 Java 编写的,但我针对此应用程序的目标用户是 Windows 用户。它需要在用户的PC一打开就运行,所以我的问题是:如何使Java应用程序在Windows系统中打开PC时自动启动?
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 程序来完成,如果可以,有没有示例代码?
采纳答案by KitsuneYMG
create a .bat file
创建一个 .bat 文件
@javaw -jar path/to/jar/Name.jar arguments
drop this in you startup directory
把它放到你的启动目录中
回答by Chandra Patni
Use Java Service Wrapper. Set wrapper.ntservice.starttype=DEMAND_START
in wrapper configuration.
使用Java 服务包装器。wrapper.ntservice.starttype=DEMAND_START
在包装器配置中设置。