jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassNotFoundException" Watch "ClassNotFoundException" New topic


paul wheaton

Joined: Dec 14, 1998
Posts: 20972

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!?"

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Rob Spoor

Joined: Oct 27, 2005
Posts: 20274

1) check the class path; print it using System.getProperty("java.class.path") when in doubt.

How To Ask Questions How To Answer Questions
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

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.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33118

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: ClassNotFoundException
It's not a secret anymore!