# Could not find or load main class

**URL:** <https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350>\
**Category:** Elasticsearch\
**Created:** [May 11, 2017, 8:30am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350 "2017-05-11T08:30:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayoub\_Benzouine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayoub_benzouine/32/18126_2.png) [@Ayoub\_Benzouine](https://discuss.elastic.co/u/Ayoub_Benzouine)\
**Post date:** [May 11, 2017, 8:30am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/1 "2017-05-11T08:30:39Z")

</div>

I am trying to install Elasticsearch 2.2.0 and I am getting this errors:  
./elasticsearch: line 75: dirname: command not found  
./elasticsearch: line 98: dirname: command not found  
./elasticsearch: line 125: uname: command not found  
./elasticsearch: line 134: hostname: command not found  
./elasticsearch: line 134: cut: command not found  
./elasticsearch: line 138: egrep: command not found  
Error: Could not find or load main class org.elasticsearch.bootstrap.Elasticsearch

I found that there was a similar topic and the problem was in the Java version. I have jdk1.8.0\_60.jdk, jdk1.8.0\_131.jdk and jdk1.6.0.jdk, so I checked my Java path in case it might be pointing on the 1.6 version but actually it is not:

macs-MacBook-Pro-2:bin mac$ echo $JAVA\_HOME  
/Library/Java/JavaVirtualMachines/jdk1.8.0\_131.jdk/Contents/Home

I even removed the 1.6 version but I'm still getting the same error.

Thank you in advance for your help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 11, 2017, 4:14pm UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/2 "2017-05-11T16:14:36Z")

</div>

What did you download exactly?

Sounds like you are running on a Mac, right?

Should be pretty much straightforward:

- Download the tar.gz
- tar xzf thefile
- cd thedir
- bin/elasticsearch

Are you doing any other step you did not mention yet?

---

<div class="post-metadata">

**Author:** ![Ayoub\_Benzouine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayoub_benzouine/32/18126_2.png) [@Ayoub\_Benzouine](https://discuss.elastic.co/u/Ayoub_Benzouine)\
**Post date:** [May 12, 2017, 7:41am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/3 "2017-05-12T07:41:37Z")

</div>

I am still getting errors:

```
   Last login: Thu May 11 18:28:39 on console
  -bash: touch: command not found
   controller:~ mac$ cd /Users/mac/Documents 
   controller:Documents mac$ tar xzf elasticsearch-5.4.0
  -bash: tar: command not found
  controller:Documents mac$ cd /Users/mac/Documents/elasticsearch-5.4.0/bin  
  controller:bin mac$ elasticsearch
  -bash: elasticsearch: command not found
  controller:bin mac$ ./elasticsearch
  ./elasticsearch: line 48: grep: command not found
  ./elasticsearch: line 108: dirname: command not found
  ./elasticsearch: line 142: dirname: command not found
  Error: Could not find or load main class org.elasticsearch.tools.JavaVersionChecker
  Elasticsearch requires at least Java 8 but your Java version from /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java does not meet this requirement
 controller:bin mac$ 

```

I downloaded it from [https://www.elastic.co/downloads/elasticsearch](https://www.elastic.co/downloads/elasticsearch)

Even the "tar" command didn't work so I had to open the file using Archive Utility.

I am thinking maybe there is something wrong in the ".bash\_profile" file. Can you please show me an example of how it looks like by default?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 12, 2017, 7:54am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/4 "2017-05-12T07:54:33Z")

</div>

Probably you screwed up your path if you modified it.

---

<div class="post-metadata">

**Author:** ![Ayoub\_Benzouine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayoub_benzouine/32/18126_2.png) [@Ayoub\_Benzouine](https://discuss.elastic.co/u/Ayoub_Benzouine)\
**Post date:** [May 12, 2017, 8:03am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/5 "2017-05-12T08:03:18Z")

</div>

I was pointing in my ES\_HOME path on another version of Elasticsearch that I don't have anymore. I have just modified the path. But still getting errors:

```
Last login: Fri May 12 09:33:34 on ttys000
-bash: touch: command not found
controller:~ mac$ cd /Users/mac/Documents/elasticsearch-5.4.0/bin 
controller:bin mac$ ./elasticsearch
./elasticsearch: line 48: grep: command not found
./elasticsearch: line 108: dirname: command not found
./elasticsearch: line 142: dirname: command not found
./elasticsearch: line 184: hostname: command not found
./elasticsearch: line 184: cut: command not found
./elasticsearch: line 188: egrep: command not found
2017-05-12 09:59:49,100 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at org.apache.logging.log4j.core.jmx.Server.register(Server.java:389)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:206)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:221)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:197)
at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:126)
at org.elasticsearch.common.logging.LogConfigurator.configureWithoutConfig(LogConfigurator.java:68)
at org.elasticsearch.cli.Command.main(Command.java:85)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)

Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchFileException: /config
Likely root cause: java.nio.file.NoSuchFileException: /config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:101)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:84)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122)
at org.elasticsearch.cli.Command.main(Command.java:88)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)
Refer to the log for complete error details.

controller:bin mac$
```

---

<div class="post-metadata">

**Author:** ![Ayoub\_Benzouine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayoub_benzouine/32/18126_2.png) [@Ayoub\_Benzouine](https://discuss.elastic.co/u/Ayoub_Benzouine)\
**Post date:** [May 12, 2017, 8:15am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/6 "2017-05-12T08:15:24Z")

</div>

It is working now. I reset my ".bash\_profile" file. As I was thinking it was because of it.

```
Last login: Fri May 12 09:59:19 on ttys000
controller:~ mac$ cd documents
controller:documents mac$ cd elas*
controller:elasticsearch-5.4.0 mac$ ls
LICENSE.txt	README.textile	config modules
NOTICE.txt	bin lib plugins
controller:elasticsearch-5.4.0 mac$ cd bin
controller:bin mac$ ls
elasticsearch elasticsearch-service.bat
elasticsearch-keystore elasticsearch-systemd-pre-exec
elasticsearch-keystore.bat	elasticsearch-translog
elasticsearch-plugin elasticsearch-translog.bat
elasticsearch-plugin.bat	elasticsearch.bat
elasticsearch-service-mgr.exe	elasticsearch.in.bat
elasticsearch-service-x64.exe	elasticsearch.in.sh
elasticsearch-service-x86.exe
controller:bin mac$ ./elasticsearch
[2017-05-12T10:11:04,197][INFO][o.e.n.Node] [] initializing ...
[2017-05-12T10:11:04,315][INFO][o.e.e.NodeEnvironment] [Is99LZf] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [6.1gb], net total_space [111.8gb], spins? [unknown], types [hfs]
[2017-05-12T10:11:04,316][INFO][o.e.e.NodeEnvironment] [Is99LZf] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-05-12T10:11:04,317][INFO][o.e.n.Node] node name [Is99LZf] derived from node ID [Is99LZfXQrSPgJ5Tiyzv3Q]; set [node.name] to override
[2017-05-12T10:11:04,318][INFO][o.e.n.Node] version[5.4.0], pid[98636], build[780f8c4/2017-04-28T17:43:27.229Z], OS[Mac OS X/10.11.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_131/25.131-b11]
[2017-05-12T10:11:05,553][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [aggs-matrix-stats]
[2017-05-12T10:11:05,553][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [ingest-common]
[2017-05-12T10:11:05,554][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [lang-expression]
[2017-05-12T10:11:05,554][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [lang-groovy]
[2017-05-12T10:11:05,554][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [lang-mustache]
[2017-05-12T10:11:05,554][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [lang-painless]
[2017-05-12T10:11:05,554][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [percolator]
[2017-05-12T10:11:05,555][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [reindex]
[2017-05-12T10:11:05,555][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [transport-netty3]
[2017-05-12T10:11:05,555][INFO][o.e.p.PluginsService] [Is99LZf] loaded module [transport-netty4]
[2017-05-12T10:11:05,556][INFO][o.e.p.PluginsService] [Is99LZf] no plugins loaded
[2017-05-12T10:11:08,039][INFO][o.e.d.DiscoveryModule] [Is99LZf] using discovery type [zen]
[2017-05-12T10:11:09,007][INFO][o.e.n.Node] initialized
[2017-05-12T10:11:09,007][INFO][o.e.n.Node] [Is99LZf] starting ...
[2017-05-12T10:11:09,327][INFO][o.e.t.TransportService] [Is99LZf] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}
[2017-05-12T10:11:12,415][INFO][o.e.c.s.ClusterService] [Is99LZf] new_master {Is99LZf}{Is99LZfXQrSPgJ5Tiyzv3Q}{t4iooNZCRBWh2HJl3xiP7Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-05-12T10:11:12,439][INFO][o.e.h.n.Netty4HttpServerTransport] [Is99LZf] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}
[2017-05-12T10:11:12,444][INFO][o.e.n.Node] [Is99LZf] started
[2017-05-12T10:11:12,449][INFO][o.e.g.GatewayService] [Is99LZf] recovered [0] indices into cluster_state
[2017-05-12T10:11:42,433][WARN][o.e.c.r.a.DiskThresholdMonitor] [Is99LZf] high disk watermark [90%] exceeded on [Is99LZfXQrSPgJ5Tiyzv3Q][Is99LZf [/Users/mac/documents/elasticsearch-5.4.0/data/nodes/0] free: 6.1gb[5.4%], shards will be relocated away from this node
[2017-05-12T10:11:42,433][INFO][o.e.c.r.a.DiskThresholdMonitor] [Is99LZf] rerouting shards: [high disk watermark exceeded on one or more nodes]

```

Thank you for your help. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 9, 2017, 8:21am UTC](https://discuss.elastic.co/t/could-not-find-or-load-main-class/85350/7 "2017-06-09T08:21:49Z")

</div>

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