• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No ClassDefFoundError

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i have a program in IO with a main method. I am trying to run the program thru the console. however, it gives me java.lang.NoClassDefFoundError.

I have configured java home, the bin and the lib folders. also added the working folder to the classpath. i also tried to go into the directory containing the .class file and run the same with the java command. However, i get the same error.

wht am i missing?
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public class NoClassDefFoundError
extends LinkageError

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you post the error message you receive we might be able to help, but there is definately something wrong in the way you are trying to access a class.
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the class public?
 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by somkiat puisungnoen:
[QB][/QB]


This is the text of the error message that i receive
:

C:\Jayashree\Examples\printHTML\classes\test\print>java printHTML
Exception in thread "main" java.lang.NoClassDefFoundError: printHTML (wrong name
: test/print/printHTML)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
 
Pitchaimani Raju
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Gopal ,
i think so, your class printHTML is under package test.print. you have to run your class from C:\Jayashree\Examples\printHTML\classes folder and you have to give the following command java test.print.printHTML. now it will work properly.

Regards,

Loga
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your code to solve this problem.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vedhas Pitkar:
Is the class public?


I think, public Class name in source code is not "printHTML".
 
Ashish Vegaraju
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

this error generally comes if ur classpath is not set correctly...do the following..

open command prompt and write this command

set CLASSPATH=%CLASSPATH%C:\j2sdk1.bla...bla...version\bin;.(semicolon followed by full stop[THIS IS IMP])

try this...if it doesnt help..let me know
Ashish.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic