DEV Community

chenglin you
chenglin you

Posted on

update jdk8 with apt in ubuntu18

Following steps are running on a ubuntu18 server vm in pve.
And jdk8 was installed with apt previously a few years ago.

  1. check current version in use
    run: java -version
    got: openjdk version "1.8.0_312"
    This version is outdated.

  2. check apt source
    run:
    sudo apt update
    then:
    run: apt list | grep jdk
    this will give something like
    openjdk-8-jdk/bionic-updates,bionic-security,now 8u372-ga~us1-0ubuntu1~18.04 amd64
    followed by [upgradable from: ...]
    This is quite obvious.

  3. upgrade
    run: sudo apt upgrade openjdk-8-jdk
    This may complain like:
    Could not get lock /var/lib/dpkg/lock-frontend - open
    This means some apt process is holding the lock.
    run: sudo ps -ef | grep apt to check related processes.
    If the processes in result are some background task of apt or apt-get like daily-apt, just wait for the background work to finish.
    If not, may have to kill the processes or contact server administrator.
    then:
    run: sudo apt upgrade openjdk-8-jdk

  4. check again
    run: java -version
    got: openjdk version "1.8.0_362"

Done.

Top comments (0)