Run any Java app as a Windows Service with AlwaysUp

How to Run Any Java Application 24/7 as a Windows Service with AlwaysUp

Ensure that your Java program (or JAR) starts automatically after a reboot and gets auto-restarted if it crashes or stops for any reason

Java is the most popular cross-platform application environment developed and maintained by Oracle.

AlwaysUp includes advanced tools to make Java start at boot and run 24/7.

The Application Advisor will help you install Java as a Windows Service with all our recommended settings — in just a few clicks. Simply select Advisor from the Application menu and follow the straightforward prompts.

To set up your Java application with AlwaysUp:

  1. Download and install AlwaysUp, if necessary.

  2. Download and install the Java runtime environment (JRE), if necessary. Please make a note of where you installed it as this will be used in a later step.

  3. Start AlwaysUp.

  4. Select Application > Add to open the Add Application window:

    Add Application

  5. On the General tab:

    • In the Application field, enter the full path to the java executable. If you installed Java in the default location, this is
      C:\Program Files\Java\jre6\bin\java.exe.

    • In the Arguments field, enter the arguments to the Java executable, along with the -Xrs parameter (which prevents the JVM from terminating when you log off). For example, if you are running the MyServer.jar file, you would specify:

      -Xrs -jar C:\MyServer\MyServer.jar

      For your reference, this page describes the command line options for java.exe.

    • In the Name field, enter the name that you will call the application in AlwaysUp. We have used My Java Server but you can specify almost anything you like.

    • If your Java application expects to be run in a specific folder (so that it can find necessary components), be sure to specify that in the Start in directory field.

    Java Windows Service: General Tab

  6. By default, a java console application will show a command window when it is run by AlwaysUp. This can be useful for debugging purposes, but if you wish to avoid seeing it, click over to the Logon tab and check the When a user logs on, don't show the application's windows... box.

    Java Windows Service: Logon Tab

  7. On the Startup tab:

    • If your Java application uses TCP/IP networking, check the Ensure that the Windows Networking components have started box.

    • If your Java application needs environment variables set for it to operate (JAVA_HOME, CLASSPATH, etc.), create a batch file that sets the required variables. The file may contain lines like this:

        set JAVA_HOME=C:\Program Files\Java\jre6\
        set CLASSPATH=C:\myserver\services.jar;C:\myserver\bootstrap.jar
      

      Check the Run the following program/batch file... box and specify the full path to the batch file in the accompanying field. We have specified:

      C:\MyServer\set-vars.bat
      in the screenshot below.


    Java Windows Service: Startup Tab

  8. Click the Save button. In a couple of seconds, an application called My Java Server will show up in the AlwaysUp window. It is not yet running though.

    Java Windows Service: Created

  9. To start your Java application, choose Application > Start "My Java Server".

    Java Windows Service: Running

  10. That's it! Next time your computer boots, your Java program will start up immediately, before anyone logs on. We encourage you to edit the application in AlwaysUp and check out the many other settings that may be appropriate for your environment.



Java application not working properly as a Windows Service?

  • Consult the AlwaysUp Troubleshooter - our online tool that can help you resolve the most common problems encountered when running an application as a windows service.
  • From AlwaysUp, select Application > Report Activity > Today... to bring up a HTML report detailing the interaction between AlwaysUp and your application. The AlwaysUp Event Log Messages page explains the more obscure messages.
  • To capture diagnostic output and error messages from Java.exe, edit your application in AlwaysUp, check the Capture output to this log file box on the Extras tab and specify the path to a new text file. Please review the contents of the file after a failed run.
  • Browse the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips
  • Contact us and we will be happy to help!

Download & Try it Free!

Download AlwaysUp and Run as a Service Today! Version 15.5 New!

8.0 MB Installer
Our 12,000+ customers include...
Compatible with Windows 11 Compatible with Windows Server 2022 Compatible with Windows 10
Over 94,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 19+ years!