unable to run javac on Ubuntu [closed]

懵懂的女人 提交于 2019-11-28 18:15:45

The javac binary (and probably other java binaries) is/are not in your user's $PATH environment variable. There are several ways you can address this:

  1. Add /usr/lib/jvm/java-6-open-jdk/bin to your user's $PATH environment variable. You can do this by adding a line similar to the following in your user's .bash_profile:

    export PATH=${PATH}:/usr/lib/jvm/java-6-open-jdk/bin

    You'll have to restart your terminal session for it to take effect.

  2. Create symbolic links to the java binaries from some directory that's already part of your path (such as /usr/bin)

    sudo ln -s /usr/lib/jvm/java-6-open-jdk/bin/java /usr/bin/
    sudo ln -s /usr/lib/jvm/java-6-open-jdk/bin/javac /usr/bin/

    BTW: There are several other java executables in /usr/lib/jvm/java-6-open-jdk/bin. I've shown the symlink commands for java and javac above. You should run similar command for any other executables you may want to use.

  3. Use the fully qualified path directly on the command line:

    $ /usr/lib/jvm/java-6-open-jdk/bin/javac

Update:

Apparently, there is an elegant, but Ubuntu-specific solution to this problem. When on an Ubuntu system, use update-java-alternatives.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!