I just used PATH system variable and had the jdk1.5.0_18\bin point to it apart from other folders. This way I was able to run my simple Java programs without any problem. I also learnt that Java installs the interpreter file java.exe in %SYSTEM_ROOT%/system32 folder. I deleted that file java.exe but my simple one liner class continued to compile from anywhere using javac and run using java.
Why then do we need these two variables , JAVA_HOME and CLASSPATH?