2016-02-13 210 views
0

我试图让我的电脑上安装java,并且遇到问题。我相信这些问题与正确配置路径有关。Java路径设置

目前,如果我在CMD线运行java,我得到如下:

用法:JAVA [-options]类[参数...] (执行类) 或Java [-options ] -jar jarfile [args ...] (执行jar文件) 其中选项包括: -d32使用32位数据模型(如果可用) -d64使用64位数据模型(如果可用) -client选择“客户端”VM -server以选择“服务器”VM 默认VM是客户端。

-cp <class search path of directories and zip/jar files> 
-classpath <class search path of directories and zip/jar files> 
       A ; separated list of directories, JAR archives, 
       and ZIP archives to search for class files. 
-D<name>=<value> 
       set a system property 
-verbose:[class|gc|jni] 
       enable verbose output 
-version  print product version and exit 
-version:<value> 
       Warning: this feature is deprecated and will be removed 
       in a future release. 
       require the specified version to run 
-showversion print product version and continue 
-jre-restrict-search | -no-jre-restrict-search 
       Warning: this feature is deprecated and will be removed 
       in a future release. 
       include/exclude user private JREs in the version search 
-? -help  print this help message 
-X   print help on non-standard options 
-ea[:<packagename>...|:<classname>] 
-enableassertions[:<packagename>...|:<classname>] 
       enable assertions with specified granularity 
-da[:<packagename>...|:<classname>] 
-disableassertions[:<packagename>...|:<classname>] 
       disable assertions with specified granularity 
-esa | -enablesystemassertions 
       enable system assertions 
-dsa | -disablesystemassertions 
       disable system assertions 
-agentlib:<libname>[=<options>] 
       load native agent library <libname>, e.g. -agentlib:hprof 
       see also, -agentlib:jdwp=help and -agentlib:hprof=help 
-agentpath:<pathname>[=<options>] 
       load native agent library by full pathname 
-javaagent:<jarpath>[=<options>] 
       load Java programming language agent, see java.lang.instrument 
-splash:<imagepath> 
       show splash screen with specified image 

查看http://www.oracle.com/technetwork/java/javase/documentation/index.html了解更多详情。

然而,当我尝试运行javac,我得到如下:

的bash:javac的:命令未找到

我试图通过以下YouTube上的视频设置的路径,但它确实似乎没有帮助。

任何意见将不胜感激。

预先感谢您。

+3

你安装了JDK还是只安装了JRE? – MadProgrammer

+0

你不需要使用git bash来运行Java –

+0

您需要JDK用于'javac'。除此之外,'java'的输出看起来很好。您需要指定类的名称(例如'java --classpath =/path/to/.class/files MyClass')或JAR(例如java -jar/path/to/app.jar)。 – kba

回答

2

安装JDK首先在您的系统中。

做完以下后

1)。我的电脑 - >右键 - >属性

2)。前进系统设置在左侧

3)。点击环境变量

4)。单击新的用户变量对于System_name

5)。变量名称: - 路径

Value:- **YOUR JDK PATH UPTO BIN FOLDER** , AT END ";" 

示例: - C:\ Program Files \ Java \ jdk1.8.0_45 \ bin;

然后在cmd中

+0

很好的答案。 @kderrick提供一条建议:确保不要搞乱PATH的其余部分。不要删除/重置PATH。只需为现有的一个添加一个新值,否则其他程序将不能使用PATH。 –

+0

谢谢@AshwinGupta我提到,点击新变量 –

0

键入JAVAJAVAC你们是不是要简单地在系统上安装Java运行程序还是要编写和执行代码?如果您只想为程序安装它,那么Java网站会提供所有用于安装Java的下载,以便在您的系统上运行。对于编写代码,我建议DrJava是一个开发环境,它既易于使用,又具有许多功能,可以让您获得强大的编码能力,一旦您了解并需要它们。如果我明白你想要做什么,我希望这会有所帮助。