How to set the java path and classpath in windows-64bit

杀马特。学长 韩版系。学妹 提交于 2019-11-29 19:57:15

问题


I have installed java on windows-64bit OS. but when I execute javac, it is failing with the

error message no such command is available". I have created following environmental variable

CLASSPATH C:\Program Files (x86)\Java\jdk1.6.0_05\lib


回答1:


Add the appropriate javac path to your PATH variable. java.exe will be found under the bin directory of your JDK. E.g.

SET PATH=%PATH%;C:\Program Files (x86)\Java\jdk1.6.0_05\bin



回答2:


Before answering your question, just wann ans this simple question : Why we need PATH and CLASSPATH?

Answer:

1) PATH: You need to set PATH to compile Java source code, create JAVA CLASS FILES and Operating System to load classes at runtime.

2) CLASSPATH: This is used by JVM and not by OS.

Answer to your question :

Just make sure you have Modified PATH variable (Windows System Environmental Variable) so that it points to bin dir which contains all exe for example: java,javac and etc. In my case it is like this : ;C:\Program Files\Java\jre7\bin.

So, it doesn't matter your system is 32 bit/64 bit until and unless you specify/Modify the PATH variable correctly.




回答3:


Actually, the most conventional way of getting it done on Windows is

  • Go to Control Panel
  • Click System
  • Open Advanced settings
  • Click Environment Variables...

Path is one of the variables under "System Variables". This is where the system will search when you try to execute a command.

  • just append the full path to the Bin folder under your Java installation path. You can copy it using Windows Explorer to avoid typing it manually
  • click OK to close the dialogs.

To verify, open the command window aka console window (for example, WindowsKey-R cmd.exe ) and run:

javac -version

If the java bin folder is in the path, the system will find and execute the javac.exe file located there, and you will see your Java version. Something like:

c:\>javac -version
javac 1.7.0_65



回答4:


Very Simple:

You need to set the two environment variables only; PATH and java

=>Right Click on My computer

=>Properties

=>Click on left hand side bar menu "Advanced system settings" => Click on "Environment Variables" button refer below fig.

=>Follow the below steps to Set User variable and System variable.

To Set User variable named as "PATH"

  • Click on "New" button in user variables section.
  • Set the variable name as "PATH" and variable value as per your java installed version.(Shown in below fig.)

To Set System variable named as "java"

  • Click on "New" button in System variable tab.

  • Set the variable name as "java" and variable value as per your java installed version.(Shown in below fig.) Refer below images for the reference.




回答5:


For me, the 'JAVA_HOME' variable should be set as a System Variable, instead of User Variable. When the 'JAVA_HOME' was changed to be a System Variable, the command 'javac' works. Also, the PATH and CLASSPATH are System Variable.



来源:https://stackoverflow.com/questions/7455753/how-to-set-the-java-path-and-classpath-in-windows-64bit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!