Ubuntu Java version (reprint)

Source: Internet
Author: User

The update-alternative in Ubuntu/debian is used to manage different versions of the same software in a system.
For example, the system may contain the GNU Java compiler, and the Sun's Java compiler. You can use Update-alternatives to set which of these are currently used.

Its principle is to create a link in the/usr/bin, point to a file in the/etc/alternatives, and some file is a link, pointing to the currently used command. For example Java commands, see the following:

$ which Java
/usr/bin/java
$ ls-l/usr/bin/java
Lrwxrwxrwx/usr/bin/java-/etc/alternatives/java
$ ls-l/etc/alternatives/java
Lrwxrwxrwx/etc/alternatives/java-/usr/lib/j2re1.5-sun/bin/java
$ ls-l/usr/lib/j2re1.5-sun/bin/java
-rwxr-xr-x/usr/lib/j2re1.5-sun/bin/java

The parameter--display can be configured for the current configuration of a software, such as:

$/usr/sbin/update-alternatives--display java
Java-status is auto.
Link currently points To/usr/lib/j2re1.5-sun/bin/java
/usr/lib/kaffe/bin/java-priority 300
Slave java.1.gz:/usr/share/man/man1/java.kaffe.1.gz
/usr/lib/j2re1.5-sun/bin/java-priority 315
Slave java.1.gz:/usr/lib/j2re1.5-sun/man/man1/java.1.gz
Current ' best ' version Is/usr/lib/j2re1.5-sun/bin/java.

Status has auto and manual two kinds. Once the user changes the system's default settings, it becomes manual. In the auto state, the system will determine which set of configurations should be used based on the priority of several sets of configurations.

Each set of configurations can be configured with multiple link, which is called Slave. In the example above, there are two sets of Java configurations. One is/usr/lib/kafe/bin/java and the other is/usr/lib/j2re1.5-sun/bin/java, each with a slave. In some cases, these slave are set to the manual of the Java command. When the configuration is changed, the help that is viewed with the man command changes accordingly.

The parameter--config can be used to change the current configuration.

$ sudo/usr/sbin/update-alternatives--config java
There is 2 alternatives which provide ' Java '.
Selection Alternative
-----------------------------------------------
1/usr/lib/kaffe/bin/java
*+ 2/usr/lib/j2re1.5-sun/bin/java
Press ENTER to keep the default*, or type selection number:1
Using '/usr/lib/kaffe/bin/java ' to provide ' Java '.

The parameter--install is used to set a new configuration. See http://blog.stevenkroon.com/2006/08/29/debian-update-alternatives/for details.

There are several files in Ubuntu that can set environment variables
1./etc/profile: The first file that is used when the operating system customizes the user environment when logging on, this file sets the environment information for each user of the system, and the file is executed when the user logs on for the first time.
2./etc/environment: The second file that the operating system uses when logging on, the system sets environment variables for environment files before reading your own profile.
3. ~/.bash_profile: The third file used when logging in is the. profile file, which each user can use to enter shell information dedicated to their own use, and when the user logs in, the file executes only once! By default, he sets some environments to play The. bashrc file for the line user. /ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
4. ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.