-5

我有一个查询,由于我主要使用 eclipse 来执行 java 类,但我想知道我是否不使用 eclipse 并且我想执行 java 程序,那么我还必须手动设置路径和类路径,我有我的jdk 在 C: 驱动器中的 java 文件夹内,我的程序位于名为 AA 的文件夹内,命名为 Temp.java ,请告知如何为此设置路径和类路径,以便从命令窗口本身执行 java 程序..!

4

2 回答 2

2

您可以设置安装 jdk bin 路径的环境路径,然后您可以从任何位置编译和运行 java 程序。

My compute->right click->system properties->advanced tab->select system variable path-> select edit->then add your jdk bin path. save the setting.

在 Windows 上设置路径

Windows 7
Select Computer from the Start menu
Choose System Properties from the context menu
Click Advanced system settings > Advanced tab
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Reopen Command prompt window, and run your java code.

参考

于 2012-08-26T04:44:28.697 回答
1

您可以使用以下方法设置当前工作目录的路径:

path=%path%;c:\Java\jdk[followedbyversion]\bin

这会临时设置路径,并且在系统重新启动时,您将不得不再次设置路径。

如果在 Windows 上工作,您可以使用环境变量永久设置路径。右键单击我的电脑 -> 属性 -> 高级系统设置 -> 环境变量 -> 然后添加一个用户环境变量,将其命名为路径并将路径设置为 jdk 的 bin。

于 2012-08-26T04:45:49.593 回答