简体   繁体   中英

Directory used in Command line to Compile&Run .java file

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 ?

您将在PATH上需要C:\\Program Files\\Java\\jdk1.7.0_05\\bin ,或者直接使用引用编译器

C:\Program Files\Java\jdk1.7.0_05\bin\javac

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM