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

I ran the command bin/elasticsearch command and got the error
Error: Could not find or load main class org.elasticsearch.bootstrap.Elasticsearch
As per previous threads I ensured that my java Home variable was set correctly and even put a direct link to jdk 1.8.0_151 in my path variable. Nevertheless I continue to have this issue. I would appreciate any advice on how to fix it.

Thanks.

Hi, I am sorry that you are having trouble. Issues like this are usually environment issues (e.g., permissions issues). Let us see if we can work through this one together.

Let us start by running from the root of the Elasticsearch installation directory:

$ bash -x ./bin/elasticsearch

By the way, what version is this? How did you install Elasticsearch (from an archive like tar.gz, or using a package manager like yum)? What user are you running Elasticsearch as? Could you also do (again from the root of the Elasticsearch installation directory):

$ ls -al ./lib

Hi!

I downloaded the 2.4.1 version of elastic search from https://www.elastic.co/downloads/past-releases/elasticsearch-2-4-1. I downloaded a zipped file and unzipped it simply using command line. I am running elastic search from the root user of my computer but I run the command through bash. I am on a windows 10 64-bit system otherwise. And upon running the recommended command I get the following output.

total 24892
drwxr-xr-x 1 kgoel 197609 0 Mar 27 16:01 ./
drwxr-xr-x 1 kgoel 197609 0 Mar 27 16:02 ../
-rw-r--r-- 1 kgoel 197609 448794 Mar 27 16:01 apache-log4j-extras-1.2.17.jar
-rw-r--r-- 1 kgoel 197609 52988 Mar 27 16:01 commons-cli-1.3.1.jar
-rw-r--r-- 1 kgoel 197609 110694 Mar 27 16:01 compiler-0.8.13.jar
-rw-r--r-- 1 kgoel 197609 79732 Mar 27 16:01 compress-lzf-1.0.2.jar
-rw-r--r-- 1 kgoel 197609 9484320 Mar 27 16:01 elasticsearch-2.4.1.jar
-rw-r--r-- 1 kgoel 197609 2256213 Mar 27 16:01 guava-18.0.jar
-rw-r--r-- 1 kgoel 197609 109723 Mar 27 16:01 HdrHistogram-2.1.6.jar
-rw-r--r-- 1 kgoel 197609 1140290 Mar 27 16:01 hppc-0.7.1.jar
-rw-r--r-- 1 kgoel 197609 280014 Mar 27 16:01 jackson-core-2.8.1.jar
-rw-r--r-- 1 kgoel 197609 50196 Mar 27 16:01 jackson-dataformat-cbor-2.8.1.jar
-rw-r--r-- 1 kgoel 197609 72874 Mar 27 16:01 jackson-dataformat-smile-2.8.1.jar
-rw-r--r-- 1 kgoel 197609 40540 Mar 27 16:01 jackson-dataformat-yaml-2.8.1.jar
-rw-r--r-- 1 kgoel 197609 914597 Mar 27 16:01 jna-4.1.0.jar
-rw-r--r-- 1 kgoel 197609 38460 Mar 27 16:01 joda-convert-1.2.jar
-rw-r--r-- 1 kgoel 197609 629506 Mar 27 16:01 joda-time-2.9.4.jar
-rw-r--r-- 1 kgoel 197609 62226 Mar 27 16:01 jsr166e-1.1.0.jar
-rw-r--r-- 1 kgoel 197609 794991 Mar 27 16:01 jts-1.13.jar
-rw-r--r-- 1 kgoel 197609 489884 Mar 27 16:01 log4j-1.2.17.jar
-rw-r--r-- 1 kgoel 197609 1576592 Mar 27 16:01 lucene-analyzers-common-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 430602 Mar 27 16:01 lucene-backward-codecs-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 2368341 Mar 27 16:01 lucene-core-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 107160 Mar 27 16:01 lucene-grouping-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 144597 Mar 27 16:01 lucene-highlighter-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 136173 Mar 27 16:01 lucene-join-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 33803 Mar 27 16:01 lucene-memory-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 172291 Mar 27 16:01 lucene-misc-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 251401 Mar 27 16:01 lucene-queries-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 402296 Mar 27 16:01 lucene-queryparser-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 232257 Mar 27 16:01 lucene-sandbox-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 197316 Mar 27 16:01 lucene-spatial3d-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 261161 Mar 27 16:01 lucene-spatial-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 246202 Mar 27 16:01 lucene-suggest-5.5.2.jar
-rw-r--r-- 1 kgoel 197609 1292696 Mar 27 16:01 netty-3.10.6.Final.jar
-rw-r--r-- 1 kgoel 197609 7024 Mar 27 16:01 securesm-1.0.jar
-rw-r--r-- 1 kgoel 197609 269295 Mar 27 16:01 snakeyaml-1.15.jar
-rw-r--r-- 1 kgoel 197609 148571 Mar 27 16:01 spatial4j-0.5.jar
-rw-r--r-- 1 kgoel 197609 49754 Mar 27 16:01 t-digest-3.0.jar

Thanks for the help!!

Thanks for the information. Do you also have the output from the following executed from the installation directory for Elasticsearch:

$ bash -x ./bin/elasticsearch

Hi, Sorry for that. Here is my output for bash -x ./bin/elasticsearch

  • IS_PACKAGED_VERSION=distributions
  • '[' distributions '!=' distributions ']'
  • CDPATH=
  • SCRIPT=./bin/elasticsearch
  • '[' -h ./bin/elasticsearch ']'
    ++ dirname ./bin/elasticsearch
  • ES_HOME=./bin/..
    ++ cd ./bin/..
    ++ pwd
  • ES_HOME=/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1
  • '[' x = x ']'
    ++ dirname ./bin/elasticsearch
  • for include in /usr/share/elasticsearch/elasticsearch.in.sh /usr/local/share/elasticsearch/elasticsearch.in.sh /opt/elasticsearch/elasticsearch.in.sh ~/.elasticsearch.in.sh "$ES_HOME/bin/elasticsearch.in.sh" "dirname "$0""/elasticsearch.in.sh
  • '[' -r /usr/share/elasticsearch/elasticsearch.in.sh ']'
  • for include in /usr/share/elasticsearch/elasticsearch.in.sh /usr/local/share/elasticsearch/elasticsearch.in.sh /opt/elasticsearch/elasticsearch.in.sh ~/.elasticsearch.in.sh "$ES_HOME/bin/elasticsearch.in.sh" "dirname "$0""/elasticsearch.in.sh
  • '[' -r /usr/local/share/elasticsearch/elasticsearch.in.sh ']'
  • for include in /usr/share/elasticsearch/elasticsearch.in.sh /usr/local/share/elasticsearch/elasticsearch.in.sh /opt/elasticsearch/elasticsearch.in.sh ~/.elasticsearch.in.sh "$ES_HOME/bin/elasticsearch.in.sh" "dirname "$0""/elasticsearch.in.sh
  • '[' -r /opt/elasticsearch/elasticsearch.in.sh ']'
  • for include in /usr/share/elasticsearch/elasticsearch.in.sh /usr/local/share/elasticsearch/elasticsearch.in.sh /opt/elasticsearch/elasticsearch.in.sh ~/.elasticsearch.in.sh "$ES_HOME/bin/elasticsearch.in.sh" "dirname "$0""/elasticsearch.in.sh
  • '[' -r /c/Users/kgoel/.elasticsearch.in.sh ']'
  • for include in /usr/share/elasticsearch/elasticsearch.in.sh /usr/local/share/elasticsearch/elasticsearch.in.sh /opt/elasticsearch/elasticsearch.in.sh ~/.elasticsearch.in.sh "$ES_HOME/bin/elasticsearch.in.sh" "dirname "$0""/elasticsearch.in.sh
  • '[' -r /c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/bin/elasticsearch.in.sh ']'
  • . /c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/bin/elasticsearch.in.sh
    ++ '[' x '!=' x ']'
    ++ ES_CLASSPATH='/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/lib/elasticsearch-2.4.1.jar:/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/lib/*'
    ++ '[' x = x ']'
    ++ ES_MIN_MEM=256m
    ++ '[' x = x ']'
    ++ ES_MAX_MEM=1g
    ++ '[' x '!=' x ']'
    ++ JAVA_OPTS=' -Xms256m'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g'
    ++ '[' x '!=' x ']'
    ++ '[' x '!=' x ']'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g -Djava.awt.headless=true'
    ++ '[' x '!=' x ']'
    ++ '[' x = x ']'
    ++ ES_GC_OPTS=' -XX:+UseParNewGC'
    ++ ES_GC_OPTS=' -XX:+UseParNewGC -XX:+UseConcMarkSweepGC'
    ++ ES_GC_OPTS=' -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75'
    ++ ES_GC_OPTS=' -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly'
    ++ '[' -n '' ']'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8'
    ++ JAVA_OPTS=' -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true'
  • break
  • '[' -x 'C:\Program Files\Java\jre1.8.0_151:C:\Program Files\Java\jdk1.8.0_151\bin/bin/java' ']'
    ++ which java
  • JAVA=/c/ProgramData/Oracle/Java/javapath/java
  • '[' '!' -x /c/ProgramData/Oracle/Java/javapath/java ']'
  • '[' -z '/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/lib/elasticsearch-2.4.1.jar:/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/lib/*' ']'
  • '[' x '!=' x ']'
  • case uname in
    ++ uname
    ++ hostname
    ++ cut -d. -f1
  • HOSTNAME=DESKTOP-19TLNMK
  • export HOSTNAME
    ++ echo
    ++ egrep -- '(^-d |-d$| -d |--daemonize$|--daemonize )'
  • daemonized=
  • '[' -z '' ']'
  • exec /c/ProgramData/Oracle/Java/javapath/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1 -cp '/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/lib/elasticsearch-2.4.1.jar:/c/Users/kgoel/Desktop/aristo-mini/elasticsearch-2.4.1/lib/*' org.elasticsearch.bootstrap.Elasticsearch start
    Error: Could not find or load main class org.elasticsearch.bootstrap.Elasticsearch

Ah, it looks like you're running on bash on Windows (or some variant, like Git bash on Windows, or Cygwin). I am sorry to say that I do not think that will work. Would you try the batch file from the command prompt (.\bin\elasticsearch.bat)?

Hi, thanks for that help!! However when I did try running the batch file in windows I got the following

C:\Users\kgoel\Desktop\aristo-mini\elasticsearch-2.4.1>.\bin\elasticsearch.bat
The filename, directory name, or volume label syntax is incorrect.

C:\Users\kgoel\Desktop\aristo-mini\elasticsearch-2.4.1>.\bin\elasticsearch
The filename, directory name, or volume label syntax is incorrect.

That one is puzzling. Let us see if we can figure it out. I suspect it might be some quoting of JAVA_HOME, so let us start there. What is the output of echo %JAVA_HOME%?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.