0

This question has so many answers, yet nothing works for me. I try to run a JAR file which I created and which depends on org.json library. I have my WebCfgSigner.jar and json-20180130.jar in C:\bin directory. It all works fine on my computer development computer:

java -jar c:\bin\WebCfgSigner.jar some parameters

I need to run it on my server (Windows Server 2016), where I installed first Java 1.8.something, then 17.0.2... All I get on the server is:

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject

I know about CLASSPATH environment variable, so I set it to all the variants below in turn, and nothing changes:

CLASSPATH=c:\bin\
CLASSPATH=c:\bin\*
CLASSPATH=c:\bin\json-20180130.jar

Then I try to add -classpath or -cp to the command line, no difference.

java -classpath c:\bin\json-20180130.jar -jar c:\bin\WebCfgSigner.jar some parameters
java -classpath c:\bin\* -jar c:\bin\WebCfgSigner.jar some parameters
java -cp c:\bin\json-20180130.jar -jar c:\bin\WebCfgSigner.jar some parameters

What else could I do? The json-20180130.jar is what works fine on my dev computer, but again not on the server...

gregko
  • 5,642
  • 9
  • 49
  • 76
  • 1
    Have you tried this https://stackoverflow.com/questions/2910115/include-external-jar-when-running-java-jar – hfontanez Feb 08 '22 at 19:49
  • 1
    Thank you, @hfontanez, that helped! The jar was looking for its components only through the declaration in MANIFEST.MF, and not paying attention to any environment settings or command line switches for classpath. – gregko Feb 08 '22 at 22:29
  • Does this answer your question? [What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?](https://stackoverflow.com/questions/1457863/what-causes-and-what-are-the-differences-between-noclassdeffounderror-and-classn) – Danubian Sailor May 27 '22 at 12:21

0 Answers0