Elasticsearch Could not create the Java Virtual Machine

14,386

Solution 1

Il looks like you are trying to launch the .bat script from a source distribution, that is the set of source files accompanying the binary distribution of ElasticSearch (the one you can run).

The src/main/resources path is typically used in java software projects to host resources that should be copied to the distribution archive, so src/main/resources/bin/elasticsearch.bat should be available at path bin/elasticsearch.bat.

If you really need ElastiSearch 2.4.6 you could:

Solution 2

disclaimer: I am not a windows user, so I probably cant help fully. But what you are seeing is the wrong configuration of the heap size. The line above

-Xms${packaging.elasticsearch.heap.min}

should be something like -Xms2g (for two gigabytes of heap). It seems some configuration service did not work as expected for the package you downloaded. You can check the elasticsearch.in.bat or just search for packaging.elasticsearch.heap.min to check where this is set and set it to whatever heap you want to assign to ES.

Share:
14,386
JonnyDevv
Author by

JonnyDevv

Updated on June 14, 2022

Comments

  • JonnyDevv
    JonnyDevv almost 2 years

    I'm trying to run elasticsearch on windows by following this tutorial. When i run bin/elasticsearch.bat i did get this message:

    Invalid initial heap size: -Xms${packaging.elasticsearch.heap.min}
    
    Error: Could not create the Java Virtual Machine.
    
    Error: A fatal exception has occurred. Program will exit.
    

    I tried inceasing memory from java by setting like this. Then i removed %JAVA_OPTS% from elasticsearch.bat line:

    "%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% %ES_PARAMS% -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" start !newparams!

    Now i get this message:

    Error: Could not find or load main class org.elasticsearch.bootstrap.Elasticsearch
    

    I'm running java last version jre1.8.0_144 x64 and elastic version 2.4.6. In the elasticsearch in wamp tutorial it says

    Now open 'elasticsearch.bat' file in 'C:\elasticsearch-2.3.2\bin\' directory

    But in the zip files is located in

    C:\elasticsearch-2.4.6\distribution\src\main\resources\bin

    Even in 2.3.2 is located in same directory. I don't know if it makes any diference.

    I have no ideas what else can i change. Any help would be nice.

    Thanks in advance

  • JonnyDevv
    JonnyDevv over 6 years
    I'm gonna try it. Where did you get that file? I went to elastics website, and then downloads. Then choosed version 2.4.6 "elastic.co/downloads/past-releases/elasticsearch-2-4-6".
  • JonnyDevv
    JonnyDevv over 6 years
    Davide Cavestro answer solved the problem. I did set -xms4g before. Thank you
  • Davide Cavestro
    Davide Cavestro over 6 years
    Glad to know it works for you. The link I pasted came exactly from the steps you mentioned.