I have just started on Java and was trying to know on the following:
1) What are the contents of the JAVA_HOME/lib directory? What would happen if this is not set correctly.
2) What is the purpose of setting the bin and the lib directories in PATH and CLASSPATH variables respectively.
The lib directory of your JDK or JRE contains libraries that Java itself needs.
It's simpler than you think:
Set the PATH so that includes the bin directory of your JDK. Your operating system uses the PATH environment variable to find executables (such as java.exe and javac.exe) to run. See the JDK installation instructions.
Do not set the CLASSPATH at all. It is not required. It is certainly not required (in fact, it would be wrong) to include the lib directory of the JDK in the CLASSPATH.
You do not need to set the JAVA_HOME environment variable. Java itself does not use it at all. Some third-party software (such as Apache Tomcat) requires it, however.
You do not need to do anything with the lib directory of the JDK.
You will find there are different ways to set the PATH, some with java home and some without. If you need java home, the instructions here have advantages.