# Logstash crashes when I run .bat file from powershell

**URL:** https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245
**Category:** Logstash
**Created:** [August 2, 2021, 5:33pm UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245 "2021-08-02T17:33:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![realj4ke](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@realj4ke](https://discuss.elastic.co/u/realj4ke)
#### Post date: [August 2, 2021, 5:33pm UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245/1 "2021-08-02T17:33:10Z")

</div>

Below is the error that I get when I try to run logstash after downloading the .zip file from the official website.

```auto
.\logstash.bat -f logstash.conf                                     
Using JAVA_HOME defined java: C:\Program Files\Java\jdk-16.0.1\ 
WARNING, using JAVA_HOME while Logstash distribution comes with a bundled JDK                                           
Error: Could not find or load main class Files\Apache                                                                   
Caused by: java.lang.ClassNotFoundException: Files\Apache                                                               
"error: jvm options parser failed; exiting"

```

What can be done here? Where do I add Files/Apache and what does Files/Apache contain?

This is my logstash.conf file

```auto
# Read input from filebeat by listening to port 5044 on which filebeat will send the data
input {
    beats {
	    type => "test"
        port => "5044"
    }
}
 
filter {
  #If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
  if [message] =~ "\tat" {
    grok {
      match => ["message", "^(\tat)"]
      add_tag => ["stacktrace"]
    }
  }
 
}
 
output {
   
  stdout {
    codec => rubydebug
  }
 
  # Sending properly parsed log events to elasticsearch
  elasticsearch {
    hosts => ["localhost:9300"]
  }
}

```

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 3, 2021, 1:46am UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245/2 "2021-08-03T01:46:44Z")

</div>

It's likely because of the space in your directory name, try removing that.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [August 3, 2021, 6:06pm UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245/3 "2021-08-03T18:06:48Z")

</div>

I realize this is not your decision, Mark, but although that is true, it is really a bug in logstash. Saying "do not have a space in the install path" when spaces in the install path have been _absolutely standard_ on Windows for years is not cool. There are only eight .bat files, totalling less than 6 KB of text. It would not be a major effort to test and fix them. Some cases have already been fixed!

There will be many variants of this, but if you install logstash, cd to the bin directory and run

```
.\logstash -f logstash.conf

```

then cmd barfs with

```
\logstash-7.14.0\logstash-core\lib\jars\animal-sniffer-annotations-1.14.jar was unexpected at this time.

```

that is due to the :concat function in logstash.bat not handling arguments with spaces

```
set CLASSPATH=%~1

```

expands to

```
set CLASSPATH=c:\Program Files (x86)\logstash-7.14.0\logstash-core\lib\jars\animal-sniffer-annotations-1.14.jar

```

logstash.bat already has `setlocal enabledelayedexpansion`, so how hard is it to do

```
set CLASSPATH=!~1!

```

instead? Of course that just gets you onto setup.bat, where

```
echo "Using bundled JDK: "c:\Program Files (x86)\logstash-7.14.0\jdk\bin\java.exe"""

```

blows up, but again, it is not much work to turn on enabledelayedexpansion in that bat file too and make it handle spaces in the directory name.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 3, 2021, 9:14pm UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245/4 "2021-08-03T21:14:18Z")

</div>

Fair point and I don't disagree with you at all!

---

<div class="post-metadata">

### Author: ![realj4ke](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@realj4ke](https://discuss.elastic.co/u/realj4ke)
#### Post date: [August 8, 2021, 4:59pm UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245/5 "2021-08-08T16:59:05Z")

</div>

I did like Mark pointed out; removed the spaces in the path of both my JAVA\_HOME and where logstash lives. It still throws the same error.

I also tried making changes listed by Badger in logstash.bat and the error I get still persists. Now he mentioned making similar changes in other batch files but I'm not familiar with writing batch files so I'm stuck.

Please suggest something that can be done here.

---

<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: [September 5, 2021, 4:59pm UTC](https://discuss.elastic.co/t/logstash-crashes-when-i-run-bat-file-from-powershell/280245/6 "2021-09-05T16:59:52Z")

</div>

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