Skip to content

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 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( Caused by: java.lang.ClassNotFoundException: org.ini4j.Ini at$ at$ at Method) at at java.lang.ClassLoader.loadClass( at sun.misc.Launcher$AppClassLoader.loadClass( at java.lang.ClassLoader.loadClass( ... 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:

import java.util.Map;   
import org.ini4j.* ;
public class Driver{
    public static void main(String[] args){
        System.out.println("running in Clock-J main()");
        String fileName = "./test.ini" ;
        File fileObject = new File(fileName);
            Ini ini = new Ini(fileObject);
        }catch(IOException e){
            String exception = e.toString() ;



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

6 People found this is helpful