Hi, The path is generally set for the exe files. To locate your javac and java commands, we set the path to the bin folder of jdk. Yes, you can execute the programs from bin itself, provided you have your java files in the same folder. The classpath environmental variable is set for the javac/java to identify the external classes used in the program. For example, if you use System.out.println, you need to tell the compiler where exactly the System class is present, hence we set the classpath to the rt.jar file present in the jre/lib. Hope this helps you. Uma...
Well, now a days Sun's Java compilers and JREs know where to find the J2SE packages, and adding rt.jar to the CLASSPATH is not needed or recommended. The CLASSPATH will likely need to be addressed when using packages on your own project, or when using classes from others that are not part of the J2SE.
I guess, while running the application; Java Runtime Environment (JRE) does not need the class files. please correct me if I am wrong? say I compiled the .java files ,which utilize some jar packages, on machine A; then moved these .class files to desktop B. where .jar files donot exist. They should run?
No, they sure won't. If they were required for compilation on machine A, the JAR files will (very likely, unless the application is deliberately coded to allow for them to be missing) be needed on machine B.