Skip to content
Advertisement

Getting ‘Exception in thread “main” java.lang.NoClassDefFoundError: org/ini4j/Ini’ error after succesfully compiling source file from the CLI

Background: I am trying to use ini4j for the purpose of parsing config files in the ini format.

I run the command: javac -classpath ini4j-0.5.4.jar Driver.java and the compilation goes smoothly…however when I attempt to run the program running: java Driver I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/ini4j/Ini at Clock.main(Clock.java:13) Caused by: java.lang.ClassNotFoundException: org.ini4j.Ini at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 1 more

From what I understand this error is a product of the jvm being able to find the class file being referenced in the error and failing. I checked the ini4j jar file and confirmed that the Ini.class file does in fact exist. Can anyone please tell me what am I missing here ?

The following is my source code:

JavaScript

Advertisement

Answer

The correct answer for my situation appears to be: java -cp .:ini4j-0.5.4.jar Driver Thanks for pointing me in the correct direction guys!!!! Using an IDE causes one to forget stuff like this. I really appreciate it!!!! Thanks!!!!!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement