I have run into into some weird runtime error. I have a json data file that I am trying to parse into my code . I am using json-simple-1.1.1.jar external library that I have added to my classpath and verified that it exists there by doing echo $CLASSPATH.
When I compile my code using javac codeTest.java the program compiles with no issues .
But when I try to run the program using java -classpath . codeTest I am receiveing the error : java.lang.NoClassDefFoundError: org/jason/simple/parser/ParseException.
I have opened the json-simple-1.1.1.jar folder and verified that ParseException.class does exist in the folder.
If I run the code without the class path (i.e. java codeTest) then I am receiving "could not find or load main class codeTest", which is expected.
There's your problem - the library may exist, but the JVM is not using it. By specifying the classpath as ., you're saying it's the current directory, and nothing else. Current directory means class files in the current directory (including package structure), but JAR files in the same directory are not included. You need to add that as well: java -classpath .;json-simple-1.1.1.jar codeTest (assuming you're on Windows, otherwise replace the ; with a :).