• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between can not find symbol and ClassNotFound Exception  RSS feed

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When does compiler gives 535: cannot find symbol and when does it gives ClassNotFound exception ?

Does Cannot find symbol means my class is referring to wrong class file ?
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClassNotFoundException is a runtime exception. It is caused most often by the Class.forName() method with a class name that could not be resolved. See the documentation of this class.

The cannot find symbol message is emitted by the compiler when he encounters a valid identifier in source code, but there is no variable, field or class (or any other syntactical element I have forgotten to list) declared which would match the identifier (535 is most probably the line number where the error occurred). This is a compile-time error, you need to rectify it before you can ever run such code.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClassNotFoundException and "cannot find symbol" are two totally unrelated things. It's a bit strange to ask what the difference between them is.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:ClassNotFoundException and "cannot find symbol" are two totally unrelated things. It's a bit strange to ask what the difference between them is.

If you have a good understanding of what they mean, then yes, they are unrelated.

But if you are just starting to learn java, on the surface, they both basically mean "I can't find what this thing is".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!