0
votes

I'm building elastic search on my mac.

First I git cloned the repo from here using the master branch: (https://github.com/elastic/elasticsearch.git)

Then I ran mvn clean package according to the instructions from the readme in root/core directory.

After the build succeeded, I ran "java -cp target/elasticsearch-2.0.0-beta1-SNAPSHOT-sources.jar org.elasticsearch.bootstrap.ElasticsearchF"

However it threw an exception saying "Error: Could not find or load main class org.elasticsearch.bootstrap.ElasticsearchF"

My java version is:

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

No sure what happened. Basically I want to add some prints to see how elastic search receives and execute the requests. Besides, during the compilation, it complains that System.out.println cannot be used in production mode(only in dedug mode).

Does anybody know how to resolve these issues?

Updates:

I upgraded my java to 8, ran another command: "java -cp target/elasticsearch-2.0.0-beta1-SNAPSHOT.jar org.elasticsearch.bootstrap.ElasticsearchF", then it threw another error to me:

java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser

So does it mean elasticsearch does not add CommandLineParser as a dependency? If so, I then need to add all the dependencies? If not, what have I missed?

Updates II:

I tried with 1.7.3 and 1.5.3 respectively and both of them gave me:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/util/IOUtils

Then I went to the folder and found there was a file called XIOUtils.java

Do I miss anything?

2

2 Answers

0
votes

You shall upgrade you version of java :

The documentation recommend installing the Java 8 update 20 or later, or Java 7 update 55 or later.

Previous versions of Java 7 are known to have bugs that can cause index corruption and data loss. Elasticsearch will refuse to start if a known-bad version of Java is used.

You can have a look to the documentation here:

https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html#jvm-version

0
votes

Actually if we want to print something, use the built-in logger.

For the second one, go to target/release/, unpack the files then run.