There's no problem with your environment variables. You have to either:
1. Tell the compiler where the sources are by using an absolute path : javac D:\Installations\JDK\bin\Program1.java
2. or Tell the compiler where the sources are by using a relative path (relative to the current directory) : javac Program1.java (in D:\Installations\JDK\bin)
I may be forgetting other choices. Putting sources in the jdk's bin directory is a bad choice though. Keep your files out of there.
Lalit Mehra wrote:no not exactly ... i meant that the files obviously were stored at the locations provided with the PATH and CLASSPATH
Let's make things clear
1. PATH is used to find executable files. Putting the JDK's bin directory allows you to execute the JDK's programs (javac, java...) from anywhere.
2. CLASSPATH is used to find compiled classes and JAR files. This tells the compiler and the JRE where to find classes. This allows you, for example, to compile some source from directory A, which uses some JARs from directory B. (There are other usages). This also allows you to run some classes from a different directory.
So what I believe it that you could run class files in D:\JFiles from anywhere, because D:\JFiles is in your PATH. What I don't believe is that you could compile classes from outside D:\JFiles, without telling the compiler where to look for the sources.
to compile do like this
This will create Program1.class in D:\Installations\JDK\bin.
to run ... ???
You have to understand that the java runtime will look for your class into any directories or JARs set in your CLASSPATH. If D:\Installations\JDK\bin is in your CLASSPATH, you can run it from anywhere, using "java Program1". You can also use the -cp flag : "java -cp D:\Installations\JDK\bin Program1". If it isn't in your CLASSPATH, you need to go D:\Installations\JDK\bin, and if the current directory is in your CLASSPATH, you can run "java Program1". To put the current directory in your CLASSPATH, you can use "java -cp . Program1".