Could not find or load main class Files

HI Team,

We are observing below issue when trying to run the logstash. Could you please help us on this.

ELK version 6.2.3
OS - Windows
JDK - 1.8

Error: Could not find or load main class Files\Java\jdk1.7.0_51\lib;D:\PageSizeT
ool\Classess\harlib-all-1.1.2\build;D:\PageSizeTool\Classess\jackson-src-1.7.9\j
ackson-src-1.7.9\src\java;D:\PageSizeTool\Classess\Selenium;D:\PageSizeTool\Clas
sess\src;;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\animal-sniffer-annotat
ions-1.14.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\commons-compiler-3
.0.8.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\error_prone_annotations
-2.0.18.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\google-java-format-1
.5.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\guava-22.0.jar;D:\SFactor
y\ELK\Logstash\logstash-core\lib\jars\j2objc-annotations-1.1.jar;D:\SFactory\ELK
\Logstash\logstash-core\lib\jars\jackson-annotations-2.9.1.jar;D:\SFactory\ELK\L
ogstash\logstash-core\lib\jars\jackson-core-2.9.1.jar;D:\SFactory\ELK\Logstash\l
ogstash-core\lib\jars\jackson-databind-2.9.1.jar;D:\SFactory\ELK\Logstash\logsta
sh-core\lib\jars\jackson-dataformat-cbor-2.9.1.jar;D:\SFactory\ELK\Logstash\logs
tash-core\lib\jars\janino-3.0.8.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\j
ars\javac-shaded-9-dev-r4023-3.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\ja
rs\jruby-complete-9.1.13.0.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\j
sr305-1.3.9.jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\log4j-api-2.9.1.
jar;D:\SFactory\ELK\Logstash\logstash-core\lib\jars\log4j-core-2.9.1.jar;D:\SFac
tory\ELK\Logstash\logstash-core\lib\jars\log4j-slf4j-impl-2.9.1.jar;D:\SFactory\
ELK\Logstash\logstash-core\lib\jars\logstash-core.jar;D:\SFactory\ELK\Logstash\l
ogstash-core\lib\jars\slf4j-api-1.7.25.jar

TIA.

Please provide JAVA_HOME value

JAVA_HOME C:\Program Files\Java\jdk1.8.0_45

This log shows
Error: Could not find or load main class Files\Java\jdk1.7.0_51\lib;D:\PageSizeT
your java pointed to different location. Try to fix it by adding
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
in your logstash.sh or logstash.bat file (after initial comment section)

I don't see any comment section when i try to check in the logstash.bat file.
could you please clarify.

@echo off
setlocal enabledelayedexpansion
set params='%*

My bad I am regerring to sh file instead of bat.

Add after 2 line or at 1 line. any location is fine I believe

i did add it in the bat file. i see the below error -
'JAVA_HOME' is not recognized as an internal or external command,

any leads?
thanks

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45

we have upgraded our jdk to below and updated the same in the bat file but still get the same error -
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161

Is it still pointing to Java 7?

we are not using Java 8
jdk1.8.0_161

I mean this error

Error: Could not find or load main class Files\Java\jdk1.7.0_51\lib;D:\PageSizeT
ool\Cla

yes, still it says the same, jdk 1.7...

Then something wrong with your Java environment variables.

run java -version from command line.

it got resolved now. it was due to CLASSPATH, not sure why but it was referring to that path

:+1:

thanks for all your suggestions.

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