Windows Service failed to be created due to JAVA_HOME environment variable configuration

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Problem

An Start Confluence Automatically on Windows as a Service is failing with the following errors shown in the command prompt window.

1 2 3 The JAVA_HOME environment variable is not defined correctly. This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE

Diagnosis

Confluence's service.bat is the script that Confluence uses to allow this instance to run automatically as Windows Service in your machine.

In the script itself, it would then first check if you have $JAVA_HOME set as an environment variable in your machine. Should you have it configured, it will then use this value to install your Confluence instance as service, however should you not have it configured, the script will then use the bundled JAVA that's shipped in your Confluence installation folder.

Please check the value of $JAVA_HOME configured in your Windows machine by executing the following command against the command prompt.

1 echo %JAVA_HOME%

Cause

The $JAVA_HOME variable must be pointing to JDK (e.g c:\programs\java\jdk1.8.0_05) not JRE (e.g. c:\programs\java\jdk1.8.0_05\jre).

Solution

Resolution

  1. Installing Java for Confluence in your Windows machine to point to the installed JDK instead of the JRE folder.

  2. Start Confluence automatically on Windows as a Service by following the steps provided in Start Confluence Automatically on Windows as a Service.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.