简体   繁体   English

Linux机器上如何配置java?

[英]How to configure java on Linux machine?

I am installing java to my Linux machine.我正在将 java 安装到我的 Linux 机器上。 Downloading the jre and jdk and extracting them did not help only - I assume some environmental variables are also needed.下载 jre 和 jdk 并提取它们并没有帮助 - 我假设还需要一些环境变量。 What all path variables are needed to be set?需要设置哪些所有路径变量? With which values?有哪些价值观? Expecting the java installs itself to <installation-dir> ?期望 java 将自身安装到<installation-dir>

Depending on your distribution it may be easiest to install from your package manager.根据您的发行版,从 package 管理器安装可能最容易。 On Ubuntu, for example, you can do:例如,在 Ubuntu 上,您可以执行以下操作:

sudo aptitude install open-jdk

Otherwise, usually the sun (oracle) version of java comes with a.bin file which you need to make executable and run as root in order to get java properly installed.否则,通常 java 的 sun(oracle)版本带有一个 .bin 文件,您需要将其设为可执行文件并以 root 身份运行才能正确安装 java。

You shouldn't need to set any environment variables to get java to work, although some applications will require you to set JAVA_HOME, JDK_HOME and/or JRE_HOME to point to the java install's bin directory.您不需要设置任何环境变量来使 java 工作,尽管某些应用程序会要求您设置 JAVA_HOME、JDK_HOME 和/或 JRE_HOME 以指向 java 安装的 bin 目录。 You can see where your java install is by looking at where the symlink from您可以通过查看符号链接的位置来查看 java 的安装位置

/etc/alternatives/java

points.点。

Get the jdk for linux.获取 linux 的 jdk。 Go to the root Directory. Go 到根目录。 Use the following commands to install.使用以下命令进行安装。

./configure make make install ./configure make 安装

PATH.= New Path where Java is installed. PATH.= 安装 Java 的新路径。

To go to the root directory for UBUNTU use command "sudo".到 go 到 UBUNTU 的根目录,使用命令“sudo”。 For FEDORA use "su".对于 FEDORA,请使用“su”。

Most Linux systems use the Gnu Java implementation by default and don't change this if you install an additional JDK.大多数 Linux 系统默认使用 Gnu Java 实现,如果您安装额外的 JDK,请不要更改此设置。 Therefore you need to explicitly make your new Java installation the default Java to be used.因此,您需要明确地使您的新 Java 安装默认 Java 被使用。 You can do so by running sudo update-alternatives --config java .您可以通过运行sudo update-alternatives --config java

If you prefer graphical configuration, you can install the "galternatives" package, which lets you configure all those application defaults in a nice little UI.如果您更喜欢图形配置,您可以安装“替代”package,它可以让您在一个漂亮的小 UI 中配置所有这些应用程序默认值。

You just need to make /usr/bin/java point to the java executable in the directory where you had extracted the JRE/JDK.您只需使/usr/bin/java指向您提取 JRE/JDK 的目录中的java可执行文件。

If you extracted it to, say, /opt/jdk1.6.0_23/bin/java , then you need to create a link like this:如果您将其解压缩到/opt/jdk1.6.0_23/bin/java ,则需要创建如下链接:

sudo ln -s /opt/jdk1.6.0_23/bin/java /usr/bin/java

Prior to this, you can choose to backup an old java installation by:在此之前,您可以选择通过以下方式备份旧的 java 安装:

sudo mv /usr/bin/java /usr/bin/java_old

Here is how I installed JRE: Install Sun Java Runtime .以下是我安装 JRE 的方法: 安装 Sun Java Runtime

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM