Removed Java 18 to replace with 17 but still 18 when run.

Sorin Srbu sorin.srbu at ki.se
Mon Nov 28 08:14:37 UTC 2022


On Wed, 2022-11-23 at 13:45 +1100, Owen Thomas wrote:
> My Java project, which uses Gradle 7.4, told me that this version of
> Gradle is incompatible with Java 18. I had a look here and was advised to
> use Java 17. So, I tried to remove Java 18 using "sudo apt remove openjdk-
> 18-jdk" followed by "sudo apt install openjdk-17-jdk". When I run java --
> version I get the following result:
> 
> openjdk 18.0.2-ea 2022-07-19
> OpenJDK Runtime Environment (build 18.0.2-ea+9-Ubuntu-222.04)
> OpenJDK 64-Bit Server VM (build 18.0.2-ea+9-Ubuntu-222.04, mixed mode,
> sharing)
> 
> I have tried to run this in a fresh CLI window, and the results are the
> same,
> 
> What do I do now?

Hello,

No need to uninstall anything (in case the older version is needed).

Just run the below update-alternativces command and set the java version to
use manually.
Output from command below for reference.

HTH.


root at lanfear2:~# 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      1111     
auto mode
1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111     
manual mode
2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081     
manual mode

Press <enter> to keep the current choice[*], or type selection number:







-- 
Sorin Srbu, Serverdrift
Tele: 08-524 84166
Karolinska Institutet Universitetsbibliotek
Avdelningen för Verksamhetsstöd
Enheten för Teknikstöd och Bildproduktion


# They say you can't buy happiness, but you can buy a 
# motorcycle, and that's pretty damn close!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 858 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20221128/232e3a46/attachment.sig>


More information about the ubuntu-users mailing list