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

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Problem

An attempt of running Confluence automatically on Windows as service is failing with the following errors shown in the command prompt window. 

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.

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).

Resolution

  1. Reconfigure $JAVA_HOME 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 this documentation.

Last modified on Nov 1, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.