java: not found during Bitbucket Server startup

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

As of BitbucketServer 5.x+, no logs are written to the BITBUCKET_INSTALL directory. The contents of catalina.out will be written to BITBUCKET_HOME/log/atlassian-bitbucket.log file.

Problem

Bitbucket Server fails to start and the following appears in the catalina.out:

./catalina.sh: 1: eval: /usr/lib/jvm/java-8-oracle/jre/bin/java/bin/java: not found

Cause

Cause #1 - Java is not installed

Java is not installed on the server hosting Bitbucket Server, or the JAVA_HOME environment variable is not set to a valid location.

Cause #2 - Incorrect JAVA_HOME location

Bitbucket Server was installed with automated installer which creates a file containing the expected value for the JAVA_HOME variable. This file is responsible for setting the JAVA_HOME variable for Bitbucket Server itself, and will use the file's JAVA_HOME variable if there is no environmental variable set.

The JAVA_HOME location changed overtime. The variable can be found in the following file depending on the current version:

  • 5.0.0 or newer: the JAVA_HOME variable is now JRE_HOME and is set in the <Bitbucket Server installation directory>/bin/set-jre-home.sh file
  • between 4.9.0 and 5.0.0: the JAVA_HOME variable is set in the <Bitbucket Server installation directory>/bin/set-java-home.sh file
  • between 3.8.0 and 4.9.0: the JAVA_HOME variable is set in the <Bitbucket Server installation directory>/bin/setenv.sh file
  • before 3.8.0: the JAVA_HOME variable is set in the <Bitbucket Server installation directory>/bin/setenv.sh file

Cause #3 - JAVA_HOME is correct for Bitbucket, but not for Opensearch

For 7.21.0 versions or newer:

Bitbucket Server was installed with automated installer and bundled JRE, but at some point a new external Java is installed.

If you only set JAVA_HOME on <Bitbucket Server installation directory>/bin/set-jre-home.sh file, it will reflect only on Bitbucket, not on Opensearch.

Resolution

Resolution #1 - Java is not installed

Make sure that Java is installed on the server hosting Bitbucket Server by following the instructions on the Install Bitbucket Data Center from an archive file page in the "Check your version of Java" paragraph, and that the JAVA_HOME environment variable is set to a valid location.

Resolution #2 - Incorrect JAVA_HOME location

Update the JAVA_HOME environmental variable or update the appropriate file depending on the installed version to reflect the new Java location. The JAVA_HOME contains bin/java. This part of the path is found automatically.

Resolution #3 - Update JAVA_HOME inside Opensearch script

After updating JAVA_HOME on Bitbucket, it's necessary to access <Bitbucket Server installation directory>/opensearch/bin/opensearch script and change JAVA_HOME to update Opensearch variables.


Last modified on May 2, 2017

Was this helpful?

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