java - linux 中的 update-alternatives 命令是什么,它有什么用?

标签 java linux

在 Linux 中安装 java 时,有一些 update-alternatives 命令的用法,因为我是 Linux 环境的新手,我想知道这个命令的作用以及它的用途

>>sudo update-alternatives --install /usr/bin/java java /usr/lib/java/JDk.../bin/java

最佳答案

基本上它告诉您的机器使用 Jave JDK 的这个替代品而不是默认的 Jave JDK,在 Linux 系统中,默认的是 OpenJDK。

手册页的简短摘录比我能写的任何答案都要好:

update-alternatives creates, removes, maintains and displays information about the symbolic links comprising the Debian alternatives system.

It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor to invoke if the user has not specified a particular preference.

Debian's alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example, if the text editors ed(1) and nvi(1) are both installed on the system, the alternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by default. The system administrator can override this and cause it to refer to /usr/bin/ed instead, and the alternatives system will not alter this setting until explicitly requested to do so.

使用 --install 你指定了一个链接、“/usr/bin/java”、一个名称“java”和一个路径“/usr/lib/java/JDK....”,然后你添加了一组替代方案系统。 link 是主链接的通用名称,name 是替代目录中其符号链接(symbolic link)的名称,path 是为主链接引入的替代项。

我希望足够清楚,这里有一个post regarding java alternatives .

对于完整的用法列表,我建议查看相同的手册页,在您的操作系统外壳上键入 man update-alternatives;

关于java - linux 中的 update-alternatives 命令是什么,它有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46890723/

相关文章:

java - 如何在jsoup解析之前暂停?

java - CXF客户端异常: Interceptor for {XXX} has thrown exception,现在展开

php - 不区分大小写的 Shell 命令不适用于 PHP Exec

Linux #打开文件限制

linux - 在Linux CLI中按位置替换特定行上的特定字符

java - 如何获取合并报告的总页数

java - 将函数传递到 Java 8 中 Stream 的过滤器方法中

java - 如何解决 java 6 ssl 错误

linux - Ubuntu/Darling - dyld : Failed to load native library: libSimpleWebKit. 所以

Ruby - Watir - PhantomJS