2016-02-13 208 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是一個開發環境,它既易於使用,又具有許多功能,可以讓您獲得強大的編碼能力,一旦您瞭解並需要它們。如果我明白你想要做什麼,我希望這會有所幫助。