But being platform independent, Java doesn't natively support Windows Services. There's no built-in way to start a JAR at boot and keep it running 24/7 on Windows.
-
If necessary, download and install your favorite Java distribution. Choose from any of the major players, such as:
Afterwards, make sure that you can run your Java application from the command line.
For example, if you have a JAR file, confirm that this command works as you expect:
java -jar [FULL-PATH-TO-YOUR-JAR-FILE]
This is important: if your Java app doesn't work from the command line, it won't work as a background service either.
-
Download and install AlwaysUp, if necessary.
-
Start AlwaysUp.
-
Select Application > Advisor to launch the Application Advisor:
-
Click Next to move past the welcome screen:
-
Choose Java (JAR/WAR) from the list of applications and click Next:
-
The Advisor will take a few seconds to examine your computer and gather information about your Java installation.
After that, it will prompt you to enter the full path to the JAR file you want to run as a service:
Click Next to move on.
-
On this screen, enter the password of your Windows account. Your application will run in this context since Java is set up correctly there:
Click Next to move on.
-
As the screen says, the Advisor has composed the best settings to run your JAR as a Windows Service.
Click Next to open the Add Application window with all the particulars.
-
At this point, the Add Application window contains all the recommended settings for running your JAR 24x7 after your PC boots.
You can cycle through the tabs and review the options that have been chosen.
And on the General tab, feel free to change the name to something you prefer.
When you're ready, click Save to record your new Java service:
-
In a few seconds, a new entry for your Java app will show up in the AlwaysUp window.
However, the state will be "Stopped" because the service is not yet running:
-
Finally, to launch your Java program as a service, choose Application > Start.
The entry will soon change to Running and Java will be doing its thing in the background:
-
And that's it! Next time your computer boots, your Java app will start up immediately, before anyone logs on.
We encourage you to edit Java in AlwaysUp and check out the many other settings that may be appropriate for your environment.
For example, you can: