When you run a Java 'program' (strictly, the main method of a class), it looks for that class in a file with the name given and with a .class extension
in the places listed in the CLASSPATH environment variable. Failure to have the right CLASSPATH set results in a spectacular series of error messages!
[trainee@easterton ~]$ java Nother
Exception in thread "main" java.lang.NoClassDefFoundError: Nother
Caused by: java.lang.ClassNotFoundException: Nother
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
[trainee@easterton ~]$ export CLASSPATH=/home/trainee/a9tom
[trainee@easterton ~]$ java Nother
*** I love Trowbridge ***
*** I am a bit crazy ***
*** 1 => 2 ***
[trainee@easterton ~]$
Note:
CLASSPATH may include a series of : separated directories (; on windows)
CLASSPATH may contain the names of jar files, in which case the class will run straight from the jar
(written 2009-04-02)
Associated topics are indexed under
J601 - Java Introduction [2536] All the Cs ... and Java too - (2009-12-13)
[2423] What is a JVM, a JRE, a JDK - components of the core Java Environment - (2009-09-26)
[1908] Java CLASSPATH explained - (2008-11-26)
[1766] Diagrams to show you how - Tomcat, Java, PHP - (2008-08-22)
[1557] Trying out our Java examples on our web site - (2008-02-27)
[1497] Training Season Starts again! - (2008-01-07)
[1466] Effective Java training - the bootcamp approach - (2007-12-09)
[1418] A Golf Club Decision - Perl to Java - (2007-11-01)
[1158] Private Java Course - A customer's pictures - (2007-04-22)
[1049] Java 6, Apache Tomcat 6. - (2007-01-21)
[871] Java oversold? - (2006-09-19)
[792] Is Java the right language to learn? - (2006-07-04)
[317] Programming languages - a comparison - (2005-05-20)
[124] PHP v Java - (2004-11-20)
[111] Training notes available under Open Distribution license - (2004-11-07)
[25] Release numbers - (2004-08-23)
Some other Articles
Make your business a DESTINATION businessSpring SprungChoosing a railway station fairly in PHPWhy do we delay new forum members through authorisation?Finding your java program - the CLASSPATH variableWhich Version of Java am I running?Answering a question with a questionWhatever next ... the joys of being an employerBusiness Networking for Melksham - 23rd AprilMySQL - looking for records in one table that do NOT correspond to records in another table