I added a jar file to my project by following these steps:
Right click on your project
Select Build Path
Click on Configure Build Path
Click on Libraries and select Add External JARs
Select the jar file from the required folder
Click and Apply and Ok
This imports my jar file just fine, and the Java compiler can detect references to the new library just fine.
When I run the application though, it crashes, saying it doesn't recognize the library:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
at com.ebook.Main.main(Main.java:14)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONObject
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
What am I doing wrong when importing this jar (json-simple
)?