何时以及为什么运行替代方案 - 在linux上安装jdk时安装java jar javac javaws [英] When and Why run alternatives --install java jar javac javaws on installing jdk in linux

查看:175
本文介绍了何时以及为什么运行替代方案 - 在linux上安装jdk时安装java jar javac javaws的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在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安装 - 版本8



Linux平台的JDK安装 - 版本7

安装JDK后,包含工具的 bin 文件夹可能无法添加到环境变量 PATH 。在终端上键入的命令需要来自 PATH 变量中指定的位置。如果没有添加 JDK \ bin ,用户需要手动配置它,如安装JDK软件



替代命令用于创建符号链接。在这里,它被指示使用命令将 javac javaw 等工具添加到 / usr / bin 默认情况下存在于 PATH 变量中。



如果(你可以在 JDK / bin &之外执行 java -version & 并非指定完整路径&&& 如果版本和套餐打印为您安装的软件包){,则无需运行替代命令。}


To install java in linux (I used CentOS, RHEL is same too), I used this command

rpm -Uvh /path/to/binary/jdk-7u55-linux-x64.rpm

and verified java

java -version

Looking at a tutorial, it says to run following 4 commands, not sure why

## 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

I know if there are multiple versions of java installed, you can select version to use from

alternatives --config java

then why to run alternative --install separately for each executable.

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 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 Software

alternatives 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.

If( you could execute 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.}

这篇关于何时以及为什么运行替代方案 - 在linux上安装jdk时安装java jar javac javaws的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆