Installing Elasticsearch on OSX Mavericks

Catalin M. picture Catalin M. · Apr 4, 2014 · Viewed 82.4k times · Source

I'm trying to install Elasticsearch 1.1.0 on OSX Mavericks but i got the following errors when i'm trying to start:

:> ./elasticsearch
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.Version
at org.elasticsearch.bootstrap.Bootstrap.buildErrorMessage(Bootstrap.java:252)
at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:236)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)

Also when i'm executing the same command with -v arg, i got this error:

:> ./elasticsearch -v
Exception in thread "main" java.lang.NoSuchFieldError: LUCENE_36
at org.elasticsearch.Version.<clinit>(Version.java:42)

Here's my environment:

Java version

>: java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

Instalation path (downloaded .tar.gz archive from elasticsearch download page and extracted here):

/usr/local/elasticsearch-1.1.0

ENV vars:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home 
CLASSPATH=/usr/local/elasticsearch-1.1.0/lib/*.jar:/usr/local/elasticsearch-1.1.0/lib/sigar/*.jar

UPDATE

i finally make it working, unfortunally not sure how because i tried a lot of changes :). But here's a list of changes i made that can help:

~/Library/Caches

/Library/Caches

  • i removed CLASSPATH env var.

  • ES_PATH and ES_HOME env vars are not set either, but i think this is not so important.

Note: now it's working also if i'm installing with brew.

Thanks.

Answer

Pierre-Louis Gottfrois picture Pierre-Louis Gottfrois · Apr 4, 2014

You should really consider using brew. It's a great tool that will take care of dependencies, version control and much more.

To install Elasticsearch using brew, simply:

brew update
brew install elasticsearch

Boom! Done.

After that follow Elasticsearch instructions :

  1. To have launchd start Elasticsearch at login:

    ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
    
  2. Then to load Elasticsearch now:

    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
    

    Or, if you don't want/need launchctl, you can just run:

    elasticsearch