4

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?

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?

Adam
  • 43,763
  • 16
  • 104
  • 144
Frank
  • 30,590
  • 58
  • 161
  • 244

2 Answers2

2

Use Java Service Wrapper. Set wrapper.ntservice.starttype=DEMAND_START in wrapper configuration.

Chandra Patni
  • 17,347
  • 10
  • 55
  • 65
2

create a .bat file

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

drop this in you startup directory

KitsuneYMG
  • 12,753
  • 4
  • 37
  • 58
  • This will work :) Make sure that you have a MANIFEST.MF, with your main class defined. – Chris Dennett Dec 30 '10 at 20:33
  • <1> Can my Java program save the above file into the Windows startup directory ? <2> Where is this Windows startup directory on the C: or D: drive ? <3> How can my Java app find out the location ? <4> Is it the same on all versions of Windows ? – Frank Dec 30 '10 at 20:57
  • @frank <1> Use notepad to create the .bat file <2> I think %USERPROFILE%\Start Menu\Programs\Startup is the directory. you could also use %ALLUSERSPROFILE% if you want it to be there for everyone <3> I have no idea what this means. How can your app find what location? <4> I have no idea. I stopped using cancerOS in '05. – KitsuneYMG Dec 31 '10 at 02:52
  • This only works after you login, not directly after computer reboot. – Michael Munsey Apr 27 '15 at 20:05
  • @MichaelMunsey True. Also irrelevant. Since the purpose is to notify a logged in user of things, one has to be logged in to make use of it. – KitsuneYMG Apr 29 '15 at 18:37