I wanted to know what are JDK and JRE in layman terms...how are they of use for programming...it will be very helpful if you explain with some practical example...also please provide some info about setting variables(like class path variable) while installing java...why we need to set these variables in environment variables...how java goes to this environment variables?
Hmm, okay. I'll give it a go and get the ball rolling on this one.
Basically, the JDK (Java Development Kit) is what you need for software development. It contains all the libraries, the compiler, and probably a bunch of other stuff that I've never had to work with and so am not familiar with. It also contains everything you need to run the programs you write. Running programs is the job of the JVM (the Java Virtual Machine). The JVM is also packaged with the JRE (Java Runtime Environment). Anyone who just wants to run java applications but doesn't care about writing them just needs the JRE.
I'm not sure exactly what you mean by the second part of the question, but the classpath is what java uses to find your classes and resources in order to load everything needed to run your application. You generally specify the classpath as an argument to the 'java' command used to run the program (-cp). If I remember right, there is also a CLASSPATH environment variable you can set to do the same thing. This might explain a bit better.