试图为一些开源项目做出贡献。我尝试在网上找到答案,尝试了 Wikipedia 如何设置它。没有工作。这越来越烦人了。我需要投入我的工作。当我在这里运行 git commit 时,我得到了:
please make sure JAVA_HOME is set to JDK8
现在,我使用 JAVA 11。我卸载了 JAVA 11,然后尝试安装 JAVA 8。没有成功,尝试再次安装 12,需要 JDK8。
echo $JAVA_HOME
给
/usr/lib/jvm/java-12-oracle
java -version
是12.0.2
我想在我的计算机上安装 Java 8 和 Java 12。并且经常在两者之间切换。我希望能够处理使用 java 8 和使用 java 12 的项目。
dpkg -L openjdk-8-jdk
给
/.
/usr
/usr/lib
/usr/lib/jvm
/usr/lib/jvm/java-8-openjdk-amd64
/usr/lib/jvm/java-8-openjdk-amd64/bin
/usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer
/usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole
/usr/lib/jvm/java-8-openjdk-amd64/include
/usr/lib/jvm/java-8-openjdk-amd64/include/jawt.h
/usr/lib/jvm/java-8-openjdk-amd64/include/linux
/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jawt_md.h
/usr/lib/jvm/java-8-openjdk-amd64/lib
/usr/lib/jvm/java-8-openjdk-amd64/lib/jconsole.jar
/usr/lib/jvm/java-8-openjdk-amd64/man
/usr/lib/jvm/java-8-openjdk-amd64/man/ja_JP.UTF-8
/usr/lib/jvm/java-8-openjdk-amd64/man/ja_JP.UTF-8/man1
/usr/lib/jvm/java-8-openjdk-amd64/man/ja_JP.UTF-8/man1/appletviewer.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/man/ja_JP.UTF-8/man1/jconsole.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/man/man1
/usr/lib/jvm/java-8-openjdk-amd64/man/man1/appletviewer.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/man/man1/jconsole.1.gz
/usr/share
/usr/share/doc
/usr/share/doc/openjdk-8-jre-headless
/usr/share/doc/openjdk-8-jre-headless/test-amd64
/usr/share/doc/openjdk-8-jre-headless/test-amd64/check-hotspot-hotspot.log.gz
/usr/share/doc/openjdk-8-jre-headless/test-amd64/check-jdk-hotspot.log.gz
/usr/share/doc/openjdk-8-jre-headless/test-amd64/check-langtools-hotspot.log.gz
/usr/share/doc/openjdk-8-jre-headless/test-amd64/failed_tests-hotspot.tar.gz
/usr/share/doc/openjdk-8-jre-headless/test-amd64/jtreg-summary-hotspot.log.gz
/usr/share/doc/openjdk-8-jre-headless/test-amd64/jtreport-hotspot.tar.gz
/usr/share/doc/openjdk-8-jdk
您可以使用“alternatives”在不同的 java 版本之间切换:
如果您正在编译一些 java 代码,也适用于 java 编译器 ( javac ):
如果您从 apt openjdk 安装了 Java 8:
那么你的java home必须是:/usr/lib/jvm/java-8-openjdk-amd64
如果 java 8 在update-alternatives中不可见,您可以使用以下命令安装它:
然后检查它的存在: