ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

ubuntu中安装java

ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

By default, Ubuntu does not come with Java (or the Java Runtime Environment, JRE) installed. However, you may need it for some programs or games like Minecraft. We will show you how to quickly and easily check if Java is installed and how to install it.

默认情况下,Ubuntu不附带Java(或Java Runtime Environment,JRE)。 但是,某些程序或游戏(例如Minecraft)可能需要它。 我们将向您展示如何快速轻松地检查是否已安装Java以及如何安装Java。

Note that Java can be vulnerable to security problems, and you should protect yourself. If you really need Java for programs or games that you run, read our article about protecting yourself from Java security problems.

请注意,Java可能容易受到安全性问题的影响,因此您应该保护自己。 如果您确实需要Java来运行的程序或游戏,请阅读有关保护自己免受Java安全性问题影响的文章

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

注意:当我们说要在本文中键入某些内容并且文本周围有引号时,请不要键入引号,除非我们另外指定。

To check which version, if any, of Java is installed, type the following at the prompt and press Enter.

要检查安装了哪个版本的Java,请在提示符下键入以下内容,然后按Enter。

java –version

java –版本

If you get a result similar to the one shown in the following image, you do not have Java installed. The list shows you which packages in your system have Java available and the command for installing java is displayed.

如果得到的结果类似于下图所示,则表明您没有安装Java。 该列表向您显示系统中哪些软件包可用Java,并显示安装Java的命令。

However, before installing Java, let’s make sure all the packages are up to date. Type the following at the prompt and press Enter.

但是,在安装Java之前,让我们确保所有软件包都是最新的。 在提示符下键入以下内容,然后按Enter。

sudo apt-get update

sudo apt-get更新

This updates all the packages in available in Ubuntu. Type your password at the prompt and press Enter.

这将更新Ubuntu中可用的所有软件包。 在提示符下输入密码,然后按Enter。

ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

When the update is done, choose which a package from the list to install java. In our example, we installed version 6. Type the following command at the prompt and press Enter.

更新完成后,从列表中选择要安装Java的软件包。 在我们的示例中,我们安装了版本6。在提示符下键入以下命令,然后按Enter。

sudo apt-get install openjdk-6-jre-headless

须藤apt-get install openjdk-6-jre-headless

Replace the last part of the command after install with the package from the list that you chose.

安装后,将命令的最后部分替换为您选择的列表中的软件包。

ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

Because you recently ran another command as root using sudo, you are not asked for your password again.

由于您最近使用sudo以root用户身份运行了另一个命令,因此不再要求您输入密码。

The progress of the installation displays and then a message displays saying how much disk space will be used. When asked if you want to continue, type a “y” and press Enter.

显示安装进度,然后显示一条消息,说明将使用多少磁盘空间。 当询问您是否要继续时,键入“ y”,然后按Enter。

ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

When the installation is done, check the version of Java again by typing “java –version” at the prompt and pressing Enter. You’ll see a result similar to the following indicating the version of Java you just installed.

安装完成后,在提示符下键入“ java –version”并按Enter,以再次检查Java的版本。 您将看到类似于以下结果,指示您刚安装的Java版本。

ubuntu中安装java_如何确定Java是否已在Ubuntu中安装以及如何安装

If you only need Java for desktop programs and games, it’s a good idea to disable Java browser integration. Again, see our article for instructions on how to do this.

如果您只需要Java用于桌面程序和游戏,则最好禁用Java浏览器集成。 同样,请参阅我们的文章以获取有关如何执行此操作的说明。

翻译自: https://www.howtogeek.com/191427/how-to-find-out-if-java-is-installed-in-ubuntu-and-how-to-install-it/

ubuntu中安装java