Surprisingly I cannot even find this information on Sun's website. Want to share your frustrations? Anyway here's the answer.
The Java launcher uses the system property called 'sun.boot.class.path' to determine where to find classes. This property is set in part when you installed Java, and in part when you run a Java program. You don't need to know the nitty gritty details. Just remember: After you install Java JDK or JRE, put Java's bin/ directory path in your system's environment variable called 'path' to make Java load its core classes and extension classes automatically.
For example, I am running Windows 7 on a 64-bit machine, and the default bin directory of Java is C:\Program Files (x86)\Java\jdk1.6.0_20\bin\. I add this path in my environment variables. Here's a screen shot of the 'Environment Variables' window on my Windows 7 desktop:
As you can see the highlighted row corresponds to variable 'path' and its first value is C:\Program Files (x86)\Java\jdk1.6.0_20\bin. I have other values and therefore I delimit them with semi-colons (;).
If you are using Linux or some other operating system simply google the way to change your environment variables! Questions?
Once you've done updating the environment variable, Java automatically looks at C:\Program Files (x86)\Java\jdk1.6.0_20\jre\lib\ext\ for extension jars, and Java automatically looks at C:\Program Files (x86)\Java\jdk1.6.0_20\lib\ and C:\Program Files (x86)\Java\jdk1.6.0_20\jre\lib\ for core jars such as rt.jar.
That means if you want to use any third party jars simply drop them in C:\Program Files (x86)\Java\jdk1.6.0_20\jre\lib\ext\ and everything should work as expected.
Incidentally if you see NoClassDefFoundError while running a Java program run "java -Verbose
Related Articles
Fixing Java No Class Def Found Error and Class Not Found Exception in MINUTES!
Solving Java JDOM Jar Cannot Find Symbol Errors!
Eclipse: How to Make a Project a Java Project?
Fixing Java No Class Def Found Error and Class Not Found Exception in MINUTES!
Solving Java JDOM Jar Cannot Find Symbol Errors!
Eclipse: How to Make a Project a Java Project?
Any questions let me know!