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...