如何在Ubuntu中设置Java_Home路径

下载PDF文件下载PDF文件

本指南介绍如何在/etc/bash.basrc配置文件中设置JAVA_HOME环境路径。很多现代应用程序都需要找到JAVA_HOME路径才能正常工作。

  1. How.com.vn 中文: Step 1 启动终端,输入sudo su以获得root权限。
  2. How.com.vn 中文: Step 2 输入which java确认Ubuntu电脑上的Java安装位置。
  3. How.com.vn 中文: Step 3 要全局设置JAVA_HOME,需要编辑bash.bashrc文件。
  4. How.com.vn 中文: Step 4 在文件末尾输入以下内容,一次输入一行。
  5. How.com.vn 中文: Step 5 第一行。
    JAVA_HOME=/usr/lib/jvm/default-java/bin
  6. How.com.vn 中文: Step 6 第二行。
    export JAVA_HOME
  7. How.com.vn 中文: Step 7 第三行。
    PATH=$PATH:$JAVA_HOME
  8. How.com.vn 中文: Step 8 第四行。
    export PATH
  9. How.com.vn 中文: Step 9 关闭终端,然后重新打开并发送命令echo $JAVA_HOME。
    这样就能获得新路径。
  10. How.com.vn 中文: Step 10 输入java -version,确认安装的Java版本。
    广告

警告

  • 不要输入以下命令的路径

    which java

  • 应输入

    JAVA_HOME=/usr/lib/jvm/default-java

广告

关于本How.com.vn

How.com.vn是一个“多人协作写作系统”,因此我们的很多文章都是由多位作者共同创作的。 为了创作这篇文章,18位用户(部分匿名)多次对文章进行了编辑和改进。 这篇文章已经被读过2,438次。
本页面已经被访问过2,438次。

这篇文章对你有帮助吗?

⚠️ Disclaimer:

Content from Wiki How 中文 language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

Notices:
  • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
  • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
  • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
  • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

广告