Java переключить версию linux

iPython R Rapid Miner

В iPython мои (черновики) упражнения с Python, в разделе «Mining» собраны материалы по R, Rapid Miner, Weka, Gate. в «Projects» фрагменты старых и заготовки для новых исследований. записано для себя, открыто для всех.

Поиск по блогу

Страницы

вторник, 12 мая 2015 г.

Как в Linux переключаться между разными версиями java?

Все началось с того, что команда java -version сообщила мне, что у меня в дистрибутиве стоит 6-ая версия, а для установки нового сервера требовалась 7-я. Я года два, как не подходил к java, потому решил не умничать, а найти мануал в инете. Мануалы нашел (ссылки здесь), но оказалось, что у меня уже стоит седьмая версия, чтобы переключиться на нее, нужно было использовать update-alternatives —config java

Сначала все выглядело вот так¶

root@kali:/home/kiss# java -version java version "1.6.0_35" OpenJDK Runtime Environment (IcedTea6 1.13.7) (6b35-1.13.7-1~deb7u1) OpenJDK Server VM (build 23.25-b01, mixed mode) 

Я подумал, что раз отно так, то это жжжж неспроста. В Kali полно java программ, так что мне нельзя сносить старую java. Лучше бы найти мануал, в котором все эти мелководные камни описаны. Потратил довольно много времени на всякие вредные описания oracle java и дебиановские штучки. Голова стала пухнуть, наверное поэтому от отчаяния набрал поиск на русском. И, о счастье, нашел исчерпывающий мануал (ссылка выше — Установка Java на Debian/Ubuntu/Mint).

! update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061 manual mode * 2 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1051 manual mode Press enter to keep the current choice[*], or type selection number:

Запускаешь и переключаешься, потом снова запускаешь и уже видишь, что активна 7-ая версия, но при запуске компьютера будет активизироваться 6-ая, поскольку у нее auto mode. Мне это и надо.

java version "1.7.0_79" OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-1~deb7u1) OpenJDK Server VM (build 24.79-b02, mixed mode)

Ниже распечатаем справочники, дабы посмотреть при случае, что еще можно напереключать.

root@kali:/home/kiss# update-alternatives --list java /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 
Usage: java [-options] class [args. ] (to execute a class) or java [-options] -jar jarfile [args. ] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM -server to select the "server" VM -zero to select the "zero" VM -jamvm to select the "jamvm" VM -avian to select the "avian" VM -dcevm to select the "dcevm" VM -hotspot is a synonym for the "client" VM [deprecated] The default VM is server, because you are running on a server-class machine. -cp -classpath A : separated list of directories, JAR archives, and ZIP archives to search for class files. -D= set a system property -verbose:[class|gc|jni] enable verbose output -version print product version and exit -version: require the specified version to run -showversion print product version and continue -jre-restrict-search | -no-jre-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:. |:] -enableassertions[:. |:] enable assertions with specified granularity -da[:. |:] -disableassertions[:. |:] disable assertions with specified granularity -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:[=] load native agent library , e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:[=] load native agent library by full pathname -javaagent:[=] load Java programming language agent, see java.lang.instrument -splash: show splash screen with specified image See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
root@kali:/home/kiss# update-alternatives --help Usage: update-alternatives [option> . ] command> Commands: --install link> name> path> priority> [--slave link> name> path>] . add a group of alternatives to the system. --remove name> path> remove path> from the name> group alternative. --remove-all name> remove name> group from the alternatives system. --auto name> switch the master link name> to automatic mode. --display name> display information about the name> group. --query name> machine parseable version of --display name>. --list name> display all targets of the name> group. --get-selections list master alternative names and their status. --set-selections read alternative status from standard input. --config name> show alternatives for the name> group and ask the user to select which one to use. --set name> path> set path> as alternative for name>. --all call --config on all alternatives. link> is the symlink pointing to /etc/alternatives/name>. (e.g. /usr/bin/pager) name> is the master name for this link group. (e.g. pager) path> is the location of one of the alternative target files. (e.g. /usr/bin/less) priority> is an integer; options with higher numbers have higher priority in automatic mode. Options: --altdir directory> change the alternatives directory. --admindir directory> change the administrative directory. --log file> change the log file. --force allow replacing files with alternative links. --skip-auto skip prompt for alternatives correctly configured in automatic mode (relevant for --config only) --verbose verbose operation, more output. --quiet quiet operation, minimal output. --help show this help message. --version show the version. 

Посты чуть ниже также могут вас заинтересовать

Источник

Change default Java version in Ubuntu 20.04 LTS

We consider this article to be an extension to the previous article – Install OpenJDK JRE / JDK in Ubuntu 20.04 LTS . As you would notice, we have already installed version 11 of OpenJDK JRE / JDK in Ubuntu 20.04 LTS release. Now, consider a scenario wherein we have also installed version 8 of OpenJDK JRE. In that case, the default version would still be the one which we have installed earlier i.e. version 11.0.7. So, in this article we would discuss how to change the default Java version in Ubuntu 20.04 LTS.

Just for clarity, we would first install OpenJDK Development Kit v11.0.7 and OpenJDK Java Runtime Environment v1.0.8_252. Thereafter, we would issue the specific command to change the default version of Java.

Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.

Install different versions of OpenJDK Development Kit and Java Runtime Environment

Since the packages are already available in standard Ubuntu repository. Therefore, first update the Ubuntu repository to make the latest version of the package available. Hence, issue the following in terminal –

Now, to install OpenJDK Development Kit v11.0.7

sudo apt install openjdk-11-jdk

Next, to install OpenJDK Java Runtime Environment v1.8.0_252

sudo apt install openjdk-8-jre

Change default Java version in Ubuntu 20.04 LTS

First, verify for the Java version installed –

It would return the output –

openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Although we already installed version 1.8.0_252, But, when we pass the java -version command then it doesn’t mention the said version. Because, as of now v11.0.7 is the default version. To change that, we need to issue command –

sudo update-alternatives --config java

It would show us all the Java versions installed. Enter the selection number for OpenJDK JRE v1.8.0_252. Again –

This time it would return with –

openjdk version "1.8.0_252" OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09) OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

In conclusion, we have discussed how to change the default version of Java in Ubuntu 20.04 LTS release.

Источник

Switching between Java Versions on Ubuntu linux

If you’re using Ubuntu Linux on your daily basis work, you’ve probably Java installed on your machine. Personally I prefer using Wepupd8 PPA to manage JAVA installation, it makes my life a lot more easier especially for updates. The Wepupd8 team didn’t add any binary for Oracle JAVA installation and they made a script to download the Oracle JAVA from Oracle website and install it straight away. So whenever Oracle will release the update, I can simple upgrade via package manager.

Working with multiple Java versions in your machine is a normal thing, especially if you’re a Java developer, and because I’m a (very) lazy person, I’m always looking for a quicker/easier way to make the switch.

Today, I’ll share with you my tip on this subject. First, let’s run the following command:

$ sudo update-alternatives —config java

Running this command shows a list of installed Java JDKs and JREs allowing one to be selected as the default that is used when java needs to be executed.

There are 5 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 auto mode 1 /usr/lib/jvm/java-6-oracle/jre/bin/java 1 manual mode 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 2 manual mode 3 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode 4 /usr/lib/jvm/java-8-oracle/jre/bin/java 3 manual mode 5 /usr/lib/jvm/java-9-oracle/bin/java 4 manual mode Press to keep the current choice[*], or type selection number: 

But I’m using it just to get the Installation path of each Java version.

Then, for each version I created a script that contain the following lines (in the example below, I’m showing the one for java 8):

sudo update-java-alternatives -s java-8-oracle export JAVA_HOME=/usr/lib/jvm/java-8-oracle/ export PATH=$PATH:$JAVA_HOME 

Note that I’m using u8.sh to make he switch to Java 8, and u9.sh for Java 9 and so on.
The final step is to add an alias in ~/.bashrc file to source our script as follow:

. # Alias alias u7='source /home/aboullaite/Utils/Java/u7.sh' alias u8='source /home/aboullaite/Utils/Java/u8.sh' alias u9='source /home/aboullaite/Utils/Java/u9.sh' 

and That’s all. Now for switching between Java versions, I only run u8, u7 or u9 😉

Источник

Как установить версию Java по умолчанию в Ubuntu / Debian

В этом руководстве я покажу вам, как установить версию Java по умолчанию в Ubuntu / Debian.

Обычно в вашей системе Ubuntu или Debian запускается более одной версии Java – по причинам, связанным с разработкой или изменением требований приложений.

Предположим, что вы установили Java 11, и ранее у вас была установлена другая версия Java, вы можете выбрать версию Java по умолчанию для использования с помощью команды update-alternatives –config java.

Проверка версий Java, установленных в Ubuntu / Debian

Чтобы получить список установленных версий Java, выполните команду:

$ update-java-alternatives --list java-1.11.0-openjdk-amd64 1101 /usr/lib/jvm/java-1.11.0-openjdk-amd64 java-8-oracle 1081 /usr/lib/jvm/java-8-oracle

Получив список версий Java, установите версию по умолчанию, выполнив команду:

$ sudo update-alternatives --config java There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 auto mode * 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 manual mode 2 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode Press to keep the current choice[*], or type selection number: 2
$ java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

То же самое можно сделать для javac.

~$ sudo update-alternatives --config javac There is 1 choice for the alternative javac (providing /usr/bin/javac). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-8-oracle/bin/javac 1081 auto mode * 1 /usr/lib/jvm/java-8-oracle/bin/javac 1081 manual mode Press to keep the current choice[*], or type selection number: 

Если JAVA_HOME настроен неправильно, выполните команду ниже, чтобы установить текущую настройку Java по умолчанию.

export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:jre/bin/java::")

Постоянство может быть достигнуто путем размещения команды экспорта в вашем .bashrc или /etc/profile

Источник

Читайте также:  Посмотреть загруженность cpu linux
Оцените статью
Adblock
detector