• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException

 
paul wheaton
Trailboss
Pie
Posts: 21179
Firefox Browser IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noobs get ClassNotFoundException often enough, I thought it would be good to make a list of the most common causes. I plan on making this new thread the "go to" thread ClassNotFoundException.

So, staff, ranchers and other smarty pants types: what is your advice for "Oh no! I got a ClassNotFoundException! What do I do!?"

 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) check the class path; print it using System.getProperty("java.class.path") when in doubt.
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it would be helpful to first know which class could not be found i.e. an application class, one belonging to a third-party library (JAR) etc.
The environment would dicate what to check specifically. Is it a 'simple' application being run from the command-line? If so, is it packaged inside a JAR file? Is the application running inside a servlet container or application server, if so which one? If it is the list of possible things to check could become quite large and very specific. Maybe even varying between different versions of the same container / application server. Though I guess at that point we'd be moving away from 'most common causes' anyway.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find the class myself first when I get a ClassNotFoundException. Usually using Eclipse's open > type for a workspace where it is found. Then I check to see if the class giving a ClassNotFoundException is on the classpath of my application. The runtime classpath (java jar dependencies/manifest) not the build path.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic