Linux安裝JDK-java: command not found&cannot execute bin​ary file

大家好,我是「Bigder」~

1、檢視JAVA版本「

java -version

提示:-bash: java: command not found,說明Linux沒有JDK環境

Linux安裝JDK-java: command not found&cannot execute bin​ary file

2、安裝匹配的JDK

安裝前,先確定

Linux系統當前版本號

使用

uname -a

命令,檢視系統版本型號:x86 64bit

Linux安裝JDK-java: command not found&cannot execute bin​ary file

3、選擇和系統型號匹配的

JDK

安裝程式

如果64bit的Linux機器安裝了,32bit的程式或者32bit的Linux機器安裝了64bit程式,

執行:

java -version

」檢視JAVA版本,會出現:

cannot execute binary file錯誤

Linux安裝JDK-java: command not found&cannot execute bin​ary file

Linux安裝JDK-java: command not found&cannot execute bin​ary file

截圖中JDK的連結為:

https://download。oracle。com/java/18/latest/jdk-18_linux-x64_bin。tar。gz

4、

使用「

wget

https://download。oracle。com/java/18/latest/jdk-18_linux-x64_bin。tar。gz

」下載檔案

Linux安裝JDK-java: command not found&cannot execute bin​ary file

5、解壓

jdk-18_linux-x64_bin。tar。gz

、得到Jdk-18資料夾

解壓指令:

tar -zxvf jdk-18_linux-x64_bin。tar。gz

解壓指令推薦閱讀:07Linux打包解壓檔案-Exiting with failure status due to previous errors

Linux安裝JDK-java: command not found&cannot execute bin​ary file

6、使用「pwd」檢視當前目錄,JDK解壓後的完整目錄為:「

/root/jdk-18

Linux安裝JDK-java: command not found&cannot execute bin​ary file

7、編輯配置檔案「profile」,使用指令:「

vim /etc/profile

01、英文輸入法狀態下,按「

shift+g

」滑鼠游標移動到「profile」的末尾,輸入「

o

」,當前「profile」檔案提示「—— INSERT ——」,代表「profile」檔案可以編輯了。

Linux安裝JDK-java: command not found&cannot execute bin​ary file

02、新增如下內容到「profile」檔案中:

JAVA_HOME=

/root/jdk-18

CLASSPATH=$JAVA_HOME/lib/

PATH=$PATH:$JAVA_HOME/bin

export PATH JAVA_HOME CLASSPATH

Linux安裝JDK-java: command not found&cannot execute bin​ary file

03、退出「profile」檔案的編輯狀態

按ESC鍵,檔案中的「—— INSERT ——」不顯示了。

英文狀態下輸入:「

:wq

」後回車,檔案「profile」修改儲存完成

Linux安裝JDK-java: command not found&cannot execute bin​ary file

Linux安裝JDK-java: command not found&cannot execute bin​ary file

04、生效「profile」檔案, 使用指令:「

source /etc/profile

Linux安裝JDK-java: command not found&cannot execute bin​ary file

9、檢視JAVA版本「

java -version

」安裝生效情況

Linux安裝JDK-java: command not found&cannot execute bin​ary file

1、表達你要的,而不是你不要的;2、表達你的感受,而不是情緒(比如,表達自己現在是憤怒的,而不是憤怒地去表達);3、表達自己的需求,而不是抱怨;4、表達自己要去的方向,而不是抱怨所在的位置(看目標,而不是陷在事情裡面)。 ———————— 變健康、變幸福、變豁達

以上,

Bigder