Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch doesn't find bundled JDK #44139

Closed
dandago opened this issue Jul 9, 2019 · 13 comments · Fixed by #46160
Closed

Elasticsearch doesn't find bundled JDK #44139

dandago opened this issue Jul 9, 2019 · 13 comments · Fixed by #46160
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team

Comments

@dandago
Copy link

dandago commented Jul 9, 2019

Elasticsearch version (bin/elasticsearch --version):

7.1.1 and 7.2.0.

Version: 7.1.1, Build: default/zip/7a013de/2019-05-23T14:04:00.380842Z, JVM: 12.0.1
Version: 7.2.0, Build: default/zip/508c38a/2019-06-20T15:54:18.811730Z, JVM: 12.0.1

Plugins installed: []

Nothing extra. Just vanilla Elasticsearch.

JVM version (java -version):

Whatever is bundled with the respective versions (see Elasticsearch version output above).

OS version (uname -a if on a Unix-like system):

Windows 10 Home
Build 17134.829

Description of the problem including expected versus actual behavior:

Even though the JDK is bundled with Elasticsearch as from version 7.0, I still have to set JAVA_HOME for it to work. Elasticsearch complains that it can't find Java bundled at the directory where it actually exists. See the thread I posted at Discuss Elastic which shows the output with Elasticsearch 7.1.1.

Steps to reproduce:

  1. Open cmd.exe
  2. Navigate to the Elasticsearch bin folder
  3. Run elasticsearch.bat

Provide logs (if relevant):

N/A

@mark-vieira mark-vieira added the :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts label Jul 9, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@rjernst
Copy link
Member

rjernst commented Jul 10, 2019

@dandago Can you please check you do not already have a JAVA_HOME set? Something like echo %JAVA_HOME% just before running elasticsearch.bat. If that is not set, can you then try running from the elasticsearch home directory instead of within the bin directory? I'm trying to narrow down where this issue might be, but I rely on our windows packaging tests, which are passing, so I'm hoping to get some more data points to help in crafting a test that would fail.

@dandago
Copy link
Author

dandago commented Jul 10, 2019

@rjernst You are right, I did have JAVA_HOME set to a directory that no longer exists. It works if I clear it.

In this case, I'm afraid the error:

could not find java in JAVA_HOME or bundled at C:\tools\elasticsearch-7.1.1\jdk

...is misleading. I would have thought that if it fails to find the JDK in JAVA_HOME then it would look for the bundled one (which exists at the directory it is mentioning), but it seems to be relying entirely on JAVA_HOME if it is set.

@1044886782
Copy link

image
this is my problem , i can't figure it out...

@1044886782
Copy link

image
this is my problem , i can't figure it out...

I finally find a way to slove this probem: the url is:https://stackoverflow.com/questions/49012969/could-not-find-java-home-elastcisearch

execute this command: set JAVA_HOME=D:\java

@cawoodm
Copy link
Contributor

cawoodm commented Aug 13, 2019

This is still an issue (Windows 10) ES 7.3.0:
image

As you can see it can find java (where it says it can't) only if we set JAVA_HOME.

In my case JAVA_HOME was already set to a JRE path so, if ES doesn't like that, it should find it's own packaged JDK.

@rjernst
Copy link
Member

rjernst commented Aug 13, 2019

@cawoodm If JAVA_HOME is set, Elasticsearch will use that. There is no attempt to discern whether the version of is meant to be used with Elasticsearch. If you don't mean to use that java with Elasticsearch, unset JAVA_HOME when starting ES.

@1044886782
Copy link

@cawoodm If JAVA_HOME is set, Elasticsearch will use that. There is no attempt to discern whether the version of is meant to be used with Elasticsearch. If you don't mean to use that java with Elasticsearch, unset JAVA_HOME when starting ES.

Yes,I've sloved this problem by setting this PATH,thanks.

@dandago
Copy link
Author

dandago commented Aug 14, 2019

@rjernst

@cawoodm If JAVA_HOME is set, Elasticsearch will use that. There is no attempt to discern whether the version of is meant to be used with Elasticsearch. If you don't mean to use that java with Elasticsearch, unset JAVA_HOME when starting ES.

If this is the behaviour, then the error shouldn't claim that it checked for the bundled JDK.

@rjernst
Copy link
Member

rjernst commented Aug 14, 2019

If this is the behaviour, then the error shouldn't claim that it checked for the bundled JDK.

I agree. The existing error message is a result of only slightly changing the old error message where we looked for JAVA_HOME and on the PATH. I will separate this out so it is clear when JAVA_HOME was used and that the path does not exist.

@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
@filmico
Copy link

filmico commented Jul 1, 2021

These was the steps I followed to run ElasticSearch 7.13.2 on windows 10

  1. Download the Java SDK from:
    https://www.oracle.com/java/technologies/javase-jdk16-downloads.html
    scroll down and download de installer for windows

    JDK by default will be installed in C:\Program Files\Java\jdk-16.0.1
    and the java.exe will reside inside the bin folder of that installation

  2. Now we need to make JavaSDK visible for all the system, so we need to add the path to the environment variables. I set this as Systems Variables no users variables

    Path add an extra path pointing to: C:\Program Files\Java\jdk-16.0.1\bin
    add a new System variables called ES_JAVA_HOME and pointing to C:\Program Files\Java\jdk-16.0.1\

  3. Run Elastic Search with CMD

    cd C:{your-elastic-search-folder}\elasticsearch-7.13.2\bin
    elasticsearch.bat

@HungYann
Copy link

HungYann commented Mar 8, 2022

I also have the same problem with u. It tells me that the java is unbundled in es, but I can print the Java Home variable like below:
image
I think the main problem is that I create a new user for es, as the root user doesn't work. However, the Java Home variable doesn't be effect on the new usr.

@pugnascotia
Copy link
Contributor

@LIU-HONGYANG From v8, Elasticsearch intentionally ignores the JAVA_HOME environment variable (#69149) and always includes a bundled JDK. If you need to override the JDK, you need to set the ES_JAVA_HOME environment variable, but we don't recommend that you do this. Your question is better suited to the support forums over at https://discuss.elastic.co/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants