注意:这是一个老问题,答案反映了当时的世界。现代的Ubuntu发行版有OpenJDK可供安装
sudo apt install default-jdk
我正在尝试在Ubuntu Linux发行版上安装Java开发工具包(JDK),但我无法安装它。
在Ubuntu上安装它的步骤是什么?
注意:这是一个老问题,答案反映了当时的世界。现代的Ubuntu发行版有OpenJDK可供安装
sudo apt install default-jdk
我正在尝试在Ubuntu Linux发行版上安装Java开发工具包(JDK),但我无法安装它。
在Ubuntu上安装它的步骤是什么?
当前回答
你可以用oraji。它可以从oracle java (.tar.gz)安装/卸载JDK或JRE。
执行sudo oraji '/path/ To /the/jdk_or_jre_archive' 如果需要卸载,请执行oraji -u命令并确认版本号。
其他回答
我只是在Ubuntu虚拟机上做了这个。我是这样做的。
Ubuntu comes with the Java JRE installed, but not the JDK. Java -version gives the JRE, not the JDK. Run javac -version. If the JDK isn't installed, you will get an error. Run the following command in the terminal to get the JDK: sudo apt install default-jdk. Now, run which javac. The output should be /usr/bin/javac. It has now been installed. IntelliJ won't let us use this path because it is the binary of javac. Go to Project Structure > Project Settings > Project. Where it says 'Project SDK', add a JDK. Then go to /usr/lib/jvm. Now you should be able to compile java projects in IntellIJ.
您可能必须编辑配置,以便IntelliJ知道在哪里查找您的主类。执行命令>编辑配置。为main类添加主类,并将项目的根目录添加为Working目录。
你可以用oraji。它可以从oracle java (.tar.gz)安装/卸载JDK或JRE。
执行sudo oraji '/path/ To /the/jdk_or_jre_archive' 如果需要卸载,请执行oraji -u命令并确认版本号。
在Debian上你可以试试
apt-get install default-jdk
参考问Ubuntu问题如何设置OpenJDK的JAVA_HOME ?,
如何在Ubuntu (Linux)下安装Open JDK (Java开发工具包)?
Open Terminal from Application Dash or press Ctrl+Alt+T Update repository: sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier sudo apt update Optional: To search available distributions of openjdk, use the following command: apt search openjdk Install the appropriate version with the following command: sudo apt install openjdk-8-jdk sudo apt install openjdk-8-source #this is optional, the jdk source code For JAVA_HOME (Environment Variable) type command as shown below, in "Terminal" using your installation path... export JAVA_HOME=/usr/lib/jvm/java-8-openjdk (Note: /usr/lib/jvm/java-8-openjdk is symbolically used here just for demostration. You should use your path as per your installation.) For PATH (Environment Variable) type command as shown below, in Terminal: export PATH=$PATH:$JAVA_HOME/bin To check your installation: java -version
在Ubuntu1604中,我遇到了“没有安装候选错误”。下面的步骤帮助我安装。
-sudo apt-get update -sudo apt-get upgrade -apt-get install software-properties-common -sudo add-apt-repository ppa:webupd8team/java -apt-get更新 -sudo apt install oracle-java8-installer