Getting 'Exception in thread "main" java.lang.NoClassDefFoundError: org/ini4j/Ini' error after succesfully compiling source file from the CLI -
background: trying use ini4j purpose of parsing config files in ini format.
i run command: javac -classpath ini4j-0.5.4.jar driver.java , compilation goes smoothly...however when attempt run program running: java driver error:
exception in thread "main" java.lang.noclassdeffounderror: org/ini4j/ini @ clock.main(clock.java:13) caused by: java.lang.classnotfoundexception: org.ini4j.ini @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:425) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:358) ... 1 more
from understand error product of jvm being able find class file being referenced in error , failing. checked ini4j jar file , confirmed ini.class file in fact exist. can please tell me missing here ?
the following source code:
import java.util.map; import java.io.ioexception; import java.io.file; 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); try{ ini ini = new ini(fileobject); }catch(ioexception e){ string exception = e.tostring() ; e.printstacktrace(); } } }
you need specify -classpath option when run program. java not automatically pick jar files passed when compiled code.
Comments
Post a Comment