# ERROR: Could not find or load main class

**URL:** <https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297>\
**Category:** Logstash\
**Created:** [June 3, 2022, 7:46am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297 "2022-06-03T07:46:30Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 3, 2022, 7:46am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/1 "2022-06-03T07:46:30Z")

</div>

Hai. I have a problem regarding Logstash start. Before this when i use Logstash for ingestion, everything works well. but now, the Logstash seems having problem with java where the error as followed:

 ![Screenshot (689)](https://us1.discourse-cdn.com/elastic/original/3X/c/1/c1c3ced91f29bc81420cee53a179f77ddd4b6501.png)

1. I already have jre11 for jar file in lib.
2. I already added java as JAVA\_HOME
3. I already reinstall logstash but no changes in error.

Do anyone have idea to solve this issue? Its important for me as I use this Logstash most of the time to ingest data for testing.

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 3, 2022, 10:12am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/2 "2022-06-03T10:12:40Z")

</div>

Hello @Wan_Nur_Athirah_Wan

in command prompt could you execute` javac -version` and `java -version`

if the command output ended up with errors , there is issue with java.

Keep posted!!! Thanks !!!

---

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 9, 2022, 7:01am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/3 "2022-06-09T07:01:11Z")

</div>

![Screenshot (690)](https://us1.discourse-cdn.com/elastic/original/3X/6/7/67b9966a61c5a0b155313b23397c84d18a257652.png)  
Hai @sudhagar_ramesh . thanks for the reply. here is my screenshot for checking the java. there is nothing error occur when checking it

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 13, 2022, 8:30am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/4 "2022-06-13T08:30:01Z")

</div>

Hello @Wan_Nur_Athirah_Wan

Inorder to launch logstash , you have to use "logstash" command which will use that file in bin folder called as "logstash" with the file type "file"

Hence please make use of below code snippet

**Example1.conf**

```auto
input
{
file 
{
path =>"G:/XXXX/XXX/<your-file.txt>"
start_position =>"beginning"
}
}

output
{
stdout
{
codec => rubydebug
}

elasticsearch
{
    hosts => "localhost:9200"
	user => "<your-es-username>"
	password => "<your-es-pwd>"
	index => "<your-index-name>"
}
}

```

run that config file with this command `logstash -f Example1.conf`

Keep Posted !!! Thanks !!! 🙂

---

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 15, 2022, 3:43am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/5 "2022-06-15T03:43:14Z")

</div>

Thanks @sudhagar_ramesh for the help. I will look into it using this suggestion. Right now i just ingesting data using python script align with Elasticsearch.

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 27, 2022, 3:25am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/6 "2022-06-27T03:25:28Z")

</div>

Hello @Wan_Nur_Athirah_Wan

Good day!!!

Hope you have tried the suggestion and looking forward on the results

---

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 27, 2022, 3:26am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/7 "2022-06-27T03:26:46Z")

</div>

Hi @sudhagar_ramesh . I just have time to look back the error. when i tried to run it, the error still the same. It cannot find the path of this logstash file. I believe if it cannot find this path, the whole thing that we want to run using logstash cannot been done. I found one topic related to this error, but theres no solution and the topic also already closed

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 27, 2022, 3:32am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/8 "2022-06-27T03:32:14Z")

</div>

Could you get the path where logstash is in and set it as environment variables .

Just copy the path -\> goto advanced settings -\> path (under System Variables) -\> paste the path and save it

then in command prompt go to that drive where it is in and just type logstash

Keep Posted!!! Thanks!!!

---

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 27, 2022, 3:39am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/9 "2022-06-27T03:39:49Z")

</div>

I already create a path for logstash by pasting the path into system variables. and run the logstash. here the result:

 ![Screenshot (709)](https://us1.discourse-cdn.com/elastic/original/3X/3/0/300a33271dbdc8eede488b6fb9f777701ac420ea.png)

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 27, 2022, 3:43am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/10 "2022-06-27T03:43:09Z")

</div>

could you try with this below command

`logstash -f .\config\logstash_wl_general.conf`

---

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 27, 2022, 3:44am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/11 "2022-06-27T03:44:48Z")

</div>

> [@sudhagar\_ramesh](#):
>
> logstash -f .\config\logstash\_wl\_general.conf

here the result:

C:\Users\Lenovo\Documents\elasticsearch-7.3.1-node-test\logstash-7.3.1\>logstash -f .\config\logstash\_wl\_general.conf  
'logstash' is not recognized as an internal or external command,  
operable program or batch file.

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 27, 2022, 3:45am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/12 "2022-06-27T03:45:30Z")

</div>

Just go to bin path of logstash and then execute

---

<div class="post-metadata">

**Author:** ![Wan\_Nur\_Athirah\_Wan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wan_nur_athirah_wan/32/101868_2.png) [@Wan\_Nur\_Athirah\_Wan](https://discuss.elastic.co/u/Wan_Nur_Athirah_Wan)\
**Post date:** [June 27, 2022, 3:47am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/13 "2022-06-27T03:47:31Z")

</div>

Sorry @sudhagar_ramesh . but when I just execute it in bin folder, the command just disappeared. and when i execute by typing manually in command, the error still the same. cannot find the main class

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [June 27, 2022, 4:30am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/14 "2022-06-27T04:30:35Z")

</div>

@Wan_Nur_Athirah_Wan

the issue with java then, please reinstall your java to fix this issue.

---

<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:** [July 25, 2022, 4:31am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class/306297/15 "2022-07-25T04:31:32Z")

</div>

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