Jump to content

Exception in thread "main" java.lang.NoClassDefFoundError:


madsovenielsen

Recommended Posts

HelloI get this error when i try to run my little application:Exception in thread "main" java.lang.NoClassDefFoundError:The compiler dont throw any errors. its only when i try to execute the applicationfileOps.java

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package backup;/** * * @author admin */public class fileOps {	public String greeting(String args)	{		return args;	}}

Main.java

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package backup;/** * * @author admin */public class Main {	/**	 * @param args the command line arguments	 */	public static void main(String[] args) {		fileOps dispGreeting = new fileOps();		dispGreeting.greeting("hello");	}}

Whats wrong and how do i fix this ?Best regards Mads

Link to comment
Share on other sites

  • 2 weeks later...

Netbeans! I belive you need to declare 'import backup.fileOps;' to use that class and make sure even thought they are in the same package they are also in the same package folder.

Link to comment
Share on other sites

  • 8 months later...

Java compiler(javac) converts *.java file into *.class file.Now this byte code is converted into machine code by the JVM.Classpath variable is used by the JVM to search *.class files in different directories.C:\java> java HelloC:\java>Exception in thread "main" java.lang.NoClassDefFoundError:HelloIt means that JVM was not able to find *.class file or simply the byte code.Even after setting the PATH Variable and CLASSPATH variable correctly this error occurs.Do you know where the problem is?It lies in the CLASSPATH Variable.In the CLASSPATH there should be .;set the classpath in enviorment variable in the following manner:name=CLASSPATHValue=.;c:\programme\jboss\lib;c:\programme\j2sdk1.4.2_08\lib;c:\programme\j2sdk1.4.2_08\jre\lib; ...yes.. a dot .. it means, that JVM will search for classes bytecode in the current directory !!

Link to comment
Share on other sites

  • 5 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...