Удалить java полностью linux

How to completely uninstall Java?

How can I completely remove all traces of Java on my system? I already know how to install it in case I need it again.

9 Answers 9

dpkg-query -W -f='$\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove sudo apt-get -y autoremove 
dpkg -l | grep ^rc | awk '' | xargs sudo apt-get -y purge 
sudo bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf 
for g in ControlPanel java java_vm javaws jcontrol jexec keytool mozilla-javaplugin.so orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200 appletviewer apt extcheck HtmlConverter idlj jar jarsigner javac javadoc javah javap jconsole jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc xulrunner-1.9-javaplugin.so; do sudo update-alternatives --remove-all $g; done 
sudo updatedb sudo locate -b '\pack200' 

@JorgeCastro, absolutely. I built those commands one by one, then piped it all together and I ran all of them in different Java installation scenarios that I have for test purposes in some workstations at work. I really paid attention to the output of grep that is piped to apt-get remove , I think that it covers almost all possibilities regarding installation by deb packages.

Although the presented sequence of commands works on most cases, I think my answer needs some improvements. Everybody, please, feel free to suggest changes that can improve it, like better explanation of each command or pointing out a scenario not covered by them.

+1 for the answer. I recently found a scenario where removing openjdk causes installation of other java packages. A workaround for this problem is disabling all of the repository and then execute the removal command.

To completely remove OpenJDK on Ubuntu 11.10 (this may or may not be sufficient on other versions of Ubuntu), run:

sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\* 

If you want instructions for removing the proprietary Oracle («Sun») version of Java, then you’ll have to specify how you installed it. (If you edit your question to indicate this and leave a comment to this answer, I’ll try to add information about how to remove that too.)

I tried the above, and it completed without error on Ubuntu 11, but after I can still run java -version and get back openjdk version «11.0.3» 2019-04-16

To uninstall Oracle Java 7, just press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, run the command below.

sudo update-alternatives --display java 

To check the setup before uninstalling Java.

Читайте также:  Cross compile linux on mac os

Next, remove symlinks

(replace the word (version)with your Java version. DO java -version to get yours. So if your version is 1.7.0_03, you would type sudo update-alternatives —remove «java» «/usr/lib/jvm/jdk1.7.0_03/bin/java» )

sudo update-alternatives --remove "java" "/usr/lib/jvm/jdk/bin/java" sudo update-alternatives --remove "javac" "/usr/lib/jvm/jdk/bin/javac" sudo update-alternatives --remove "javaws" "/usr/lib/jvm/jdk/bin/javaws" 

verify that the symlinks were removed

java -version javac -version which javaws 

The next 2 commands must be type excatly perfectly to avoid permanently destroying your system.

cd /usr/lib/jvm sudo rm -rf jdk
sudo update-alternatives --config java sudo update-alternatives --config javac sudo update-alternatives --config javaws 

Delete the line with JAVA_HOME 1

To uninstall OpenJDK (if installed). First check which OpenJDK packages are installed.

sudo dpkg --list | grep -i jdk 
sudo apt-get purge openjdk* 

Uninstall OpenJDK related packages.

sudo apt-get purge icedtea-* openjdk-* 

Check that all OpenJDK packages have been removed.

sudo dpkg --list | grep -i jdk 

Источник

Как удалить Java в Ubuntu

Java — это очень популярный язык программирования, разработанный в компании Sun Microsystems, ныне принадлежащей корпорации Oracle. Существует две реализации Java открытая и свободная OpenJDK и проприетарная Oracle Java.

Если вы захотите установить одну из них, а другая уже установлена, то первую придется удалить. В этой статье будет рассмотрено удаление Java в Ubuntu 20.04, а также будет показано как определять тип и версию Java установленной на устройстве.

Как удалить Java в Ubuntu 20.04

1. Как узнать тип Java

Перед удалением Java с компьютера сначала необходимо узнать какой тип Java установлен в системе. Если Java ставилась только для запуска приложений, скорее всего это будет JRE (Java Runtime Environment — содержит только окружение для запуска программ). Если Java устанавливалась для разработки ПО, то в данном случае будет одна из следующих версий — Open JDK (полностью открытая версия) или Oracle Java (проприетарная версия от Oracle с дополнительными возможностями и поддержкой).

2. Как узнать версию Java

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

lqPbgAAAABJRU5ErkJggg==

В данном примере в системе установлена Java с типом JRE и версией 11.0.13.

3. Как узнать способ установки Java

Иногда требуется определить способ установки Java. Чтобы узнать это, необходимо выполнить команду:

p0jHdoEuSmwtbQCBhzO0EuZeTmzeXVz+R9nRK3X29QfyzSfSQHnDxtGJLL6gMjScGHHdfnOUW2OrqrgGtWL5OoXe41s4DiQv8PLa8RCI6ortkAAAAASUVORK5CYII=

Если команда ничего не вернула значит в система установлена Java от Oracle. Чтобы это проверить необходимо выполнить команду:

8HLBVrU0dn+qsAAAAASUVORK5CYII=

Также из вывода команды можно узнать, установлен ли пакет из официального репозитория или же из стороннего репозитория. На скриншоте выше можно увидеть, что Java в системе установлен при помощи стороннего репозитория под названием linuxprising. Если в выводе команды имя репозитория не отображается, значит Java была установлена при помощи официального репозитория Ubuntu.

4. Удаление Java

Для удаления Java из Ubuntu необходимо использовать команду:

sudo apt purge oracle-java11*

we3dfla7yABGwAAAABJRU5ErkJggg==

Команда выше удалит версию Java от Oracle. Если в системе установлена бесплатная версия (OpenJDK) необходимо выполнить следующую команду:

Также вместо 11 версии необходимо подставить ту, которая установлена в системе.

Выводы

В этой статье было описано удаление Java в Ubuntu 20.04. Сама процедура удаления несложная и буквально выполняется при помощи одной команды. Надеюсь, информация из статьи была вам полезной.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

How to uninstall Java from Ubuntu

Why do we need Java on our computers? There are tons of applications developed using the java environment, so we need to install java on our computers to make the java-based application run with no difficulty.

Читайте также:  Best editors for linux

In many cases, you may need to remove java from your computer, such as installing the latest version of java or freeing up space from your machine. Installing Java on Ubuntu is pretty straightforward, but uninstalling it is a hard nut to crack for many folks. In this guide, we will learn how many versions of java are there, what distinguishes them, and how to erase them from your computer completely.

How to check the type of Java on Linux (Ubuntu):

Before erasing java from your device, the first check is to identify what type of java you have on your PC. If you have installed java just to run the java applications, it would most probably “Java Runtime Environment (JRE).” Or, if you have installed java for development purpose, then you may have one of the following:

The difference between “Open JDK” and “Oracle Java” is that the former is open-source, whereas the latter is license-based. Oracle Java is much better when it comes to performance and stability.

How to identify the Java version on Linux (Ubuntu):

Before uninstalling java from your PC, it is essential to know which version of java you have got. To check it launch terminal by pressing “ctrl+alt+t” and type the below-mentioned command:

The above command will also indicate whether the version of java is “Open JDK” or “Oracle JDK.”

Standard output if the version is “OpenJDK”:

Standard output if the version is “Oracle Java”:

If you don’t have any version of java on your machine, the standard output will display it and provide some commands to install it.

How to switch versions of Java on Linux (Ubuntu):

Interestingly, you can have more than one versions of java on your device, and you can check and switch any of them by using the command mentioned below:

The above command is displaying the different versions of java I have on my PC. To switch, simply type the number and press “Enter.”

How to check the installation method of Java on Linux (Ubuntu):

In some cases, it is crucial to identify the method of installation of java. To check it, use the command:

The above output will indicate whether the package is installed from an official repository or a third-party repository. The above screenshots are demonstrating that “Oracle Java” is installed using the third-party repository “Linux pricing,” whereas “OpenJDK” is installed using the official Ubuntu repository.

How to uninstall Java from Linux (Ubuntu):

In the above discussion, we learned that there are multiple versions of java; you can have all of them on your PC at a time and conveniently switch them. Various approaches can be used to delete java from ubuntu. To completely erase “OpenJDK,” use:

Источник

Разработка приложений Android, iOS, веб и обо всем 🙂

sudo apt-get update apt-cache search java | awk '' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e 'java-common' | xargs sudo apt-get -y remove sudo apt-get -y autoremove 
dpkg -l | grep ^rc | awk '' | xargs sudo apt-get -y purge 
sudo bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf 
for g in ControlPanel java java_vm javaws jcontrol jexec keytool mozilla-javaplugin.so orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200 appletviewer apt extcheck HtmlConverter idlj jar jarsigner javac javadoc javah javap jconsole jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc xulrunner-1.9-javaplugin.so; do sudo update-alternatives --remove-all $g; done 
sudo updatedb sudo locate -b '\pack200' 

Если вывод предыдущей команды показал что-то вроде этого: /path/to/jre1.6.0_34/bin/pack200 , удалите родительский директорий bin, как здесь: sudo rm -rf /path/to/jre1.6.0_34 .

Читайте также:  Cad software for linux

Источник

Uninstall Java From Ubuntu

Sagar Sharma

Uninstall Java packages in Ubuntu

Once you are done with your Java projects, you may want to remove Java from Ubuntu.

So in this guide, I will walk you through the uninstallation process for different scenarios:

  • Removal process if you used the apt package manager for the installation
  • Uninstallation if you manually installed .deb package

So let’s start with the first one.

How to uninstall Java from Ubuntu using apt

There are 2 ways by which you can install Java in Ubuntu:

And using Ubuntu, you can also specify which version you want to install of JDE and JRE.

So I will be addressing all of them.

Remove JDK from Ubuntu (Default version)

So if you installed a default version given by the apt of JDK, you will have to use the following command to remove the JDK:

sudo apt remove default-jdk

Remove JRE from Ubuntu (Default version)

And if you’ve installed the default version of JRE with apt, all you have to do is execute the following command for removal:

sudo apt remove default-jre

But what if you went with a specific version of JDK and JRE?

Remove a specific version of JDK from Ubuntu

So if you’ve installed a specific version of JDK, for removal, you will have to execute the apt remove command in the following manner:

sudo apt remove openjdk-[version_no]-jdk

For reference, I have installed JDK version 17 so if I were to remove it, I will be using the following:

sudo apt remove openjdk-17-jdk

Remove a specific version of JRE from Ubuntu

If you installed a specific version of JRE on your Ubuntu machine, you can use the similar command syntax as above to remove JRE:

sudo apt remove openjdk-[version_no]-jre

So let’s say I want to remove the JRE version 17, then, I will be using the following:

sudo apt remove openjdk-17-jre

How to remove Java manually from Ubuntu

This section is useful for those who used the .deb file to install Java in Ubuntu.

The first step is to find the name of the installed package as you have to know the exact name of the package for removal.

To do so, here, I will be using the grep command with the apt command:

apt list --installed | grep -w 'jdk\|local'

If you get multiple results, look for the [installed,local] and the first word will be the package name:

find the name of manually installed .deb package in ubuntu

Once you find the package name, you can use the traditional apt remove command to remove the package:

sudo apt remove [package_name]

In my case, its jdk-17 so I will be using the following command for uninstallation:

Want to install Java again? Here you have it

In case you want to install Java again, we have a detailed guide for that purpose covering almost every aspect of installing Java:

I hope you will find this guide helpful.

And if you have any questions, drop a comment.

Источник

Оцените статью
Adblock
detector