java - NoClassDefFoundError found! -
import java.io.*; public class arrayapp{ public static void main(string[] args){ system.out.println("lllll"); } // end main() } // end class arrayapp
i error when run application after compiling it.
exception in thread "main" java.lang.noclassdeffounderror: arrayapp caused by: java.lang.classnotfoundexception: arrayapp @ java.net.urlclassloader$1.run(urlclassloader.java:202) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:190) @ java.lang.classloader.loadclass(classloader.java:307) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:301) @ java.lang.classloader.loadclass(classloader.java:248) not find main class: arrayapp. program exit.
you need make sure class file in classpath. assuming using default package (i.e. no package declaration), need tell java find class when run it. let's assume arrayapp.class
file in same directory. need run this:
java -cp . arrayapp
the option -cp
, following .
tell java classes in current directory. longer name -cp
-classpath
, can use well.
also note space between classpath , class name. path base directory of class files located. if compiled them directory named "bin" change way call java this:
java -cp bin/ arrayapp
the "arrayapp" qualified class name.
Comments
Post a Comment