I installed JDK on my PC running windows XP, the default directory of JDK is :
C:\Program Files\Java\jdk1.7.0_05\bin
I’m following the tutorial to do a sample
My source file named HelloWorld is in another directory : E:\NotePad\Code
As the tutorial says : “To compile your source file, change your current directory to the directory where your file is located” , so I change my Command’s current directory to E:\NotePad\Code , but here comes the problem which is saying ‘javac’ is not recognized as an internal or external command
Well, the tutorial has a solution to this problem, it seems that I should change Command Line’s current directory to where the JDK is installed which is : C:\Program Files\Java\jdk1.7.0_05\bin
After I finish it, I try this commond : javac HelloWorld.java to compile the file, but it says
javac : cannot find file : HelloWorld.java
It means that the HelloWorld.java file in E:\NotePad\Code can’t be compiled by the JDK which is installed in C:\Program Files\Java\jdk1.7.0_05\bin
I try putting the HelloWorld.java file in C:\Program Files\Java\jdk1.7.0_05\bin , it works fine
So the question is : How can I Compile&Run a file with the JDK installed in a different directory ?
You will either need
C:\Program Files\Java\jdk1.7.0_05\binon yourPATH, or reference the compiler directly using