centos7下javac:未找到命令的問題

在linux下編譯java程序,執行javac編譯生成class文件時,在centos7終端輸入如,javac hello.java    會提示未找到指令,但用java -verison測試環境變量是沒問題的java

百度了很久,說的很複雜,從新再linux配置環境變量,輸入 vi /etc/profile進入,添加如下代碼:linux

export JAVA_HOME=/usr/local/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

再測試,最後也沒有成功centos

後來在stackoverflow上看到了這個ide

84 down vote accepted
You installed the Java Runtime Environment (JRE) only, which does not contain javac. For javac, you have to install the OpenJDK Development Environment. You can install java-devel or java-1.6.0-openjdk-devel, which both include javac.測試

By the way: you can find out which package provides javac with a yum search, e.g.centos7

su -c 'yum provides javac'
Another note: using yum and openjdk is only one possibility to install the JDK. Many people prefer Sun/Oracle's "original" SDK. See How to install Java SDK on CentOS? and links for alternatives.spa

 

大意就是咱們用yum來裝原生的就好了.net

在終端輸入code

yum install java-develblog

執行安裝

再測試就好了


補充:Vi編輯經常使用快捷鍵

複製:ctrl+insert

粘貼:shift+insert

按Esc保存退出編譯,shift+zz退出本文轉自:https://blog.csdn.net/yalecaltech/article/details/70158620

相關文章
相關標籤/搜索