何时以及为什么运行替代方案 - 在linux上安装jdk时安装java jar javac javaws [英] When and Why run alternatives --install java jar javac javaws on installing jdk in linux
问题描述
要在linux中安装java(我使用CentOS,RHEL也一样),我使用了这个命令
rpm -Uvh / path /到/ binary / jdk-7u55-linux-x64.rpm
并验证了java
java -version
看一个教程,它说要运行以下4个命令,不知道为什么
## java ##
alternative --install / usr / bin / java java / usr / java / latest / jre / bin / java 200000
## javaws ##
alternative --install / usr / bin / javaws javaws / usr / java / latest / jre / bin / javaws 200000
##只安装javac
替代方案--install / usr / bin / javac javac / usr / java / latest / bin / javac 200000
## jar ##
alternative --install / usr / bin / jar jar / usr / java / latest / bin / jar 200000
我知道是否安装了多个版本的java,你可以选择使用的版本
alternatives --config java
然后为什么要这样做为每个可执行文件分别运行 alternative --install
。
我见过
这个问题,但没有得到我的问题回答
在Linux上安装JDK时,它的安装取决于包的类型,版本和分发。您可以参考以下链接获取有关linux上安装位置的信息:
Linux平台的JDK安装 - 版本7 / p> 安装JDK后,包含工具的 如果(你可以在 To install java in linux (I used CentOS, RHEL is same too), I used this command and verified java Looking at a tutorial, it says to run following 4 commands, not sure why I know if there are multiple versions of java installed, you can select version to use from then why to run I've seen
this question but doesn't get my answer When you install JDK on Linux, it it gets installed depends on the type of package, version and distribution. You can refer to the following links for information about the installation location on linux: JDK Installation for Linux Platforms - Version 8 JDK Installation for Linux Platforms - Version 7 Once you install JDK, the If( you could execute 这篇关于何时以及为什么运行替代方案 - 在linux上安装jdk时安装java jar javac javaws的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
bin
文件夹可能无法添加到环境变量 PATH
。在终端上键入的命令需要来自 PATH
变量中指定的位置。如果没有添加 JDK \ bin
,用户需要手动配置它,如安装JDK软件
替代
命令用于创建符号链接。在这里,它被指示使用命令将 javac
, javaw
等工具添加到 / usr / bin
默认情况下存在于 PATH
变量中。
JDK / bin
&之外执行 java -version
& 并非指定完整路径&&& 如果版本和套餐打印为您安装的软件包){,则无需运行替代
命令。} rpm -Uvh /path/to/binary/jdk-7u55-linux-x64.rpm
java -version
## java ##
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000
## Install javac only
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
## jar ##
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000
alternatives --config java
alternative --install
separately for each executable.bin
folder containing tools might not get added to the environment variable PATH
. Commands typed on the terminal needs to be from the locations specified in the PATH
variable. In cases when JDK\bin
does not get added, the user would need to configure it manually as mentioned in Installing the JDK Softwarealternatives
command is being used to create a symbolic link. Here, it is being directed to use the command to add the tools like javac
, javaw
to /usr/bin
which exists in the PATH
variable by default.java -version
outside of JDK/bin
&& not by specifying the complete path && if the version and bundle prints to be as that of package you installed ){ you need not run the alternatives
command.}