SUMMARY How to install Oracle JDK without privileged access
Hi dear colleagues,
Recently, I had an interesting challenge from a Java developer.
Question
How to install Oracle JDK without privileged access for quick testing on RHEL server?
Without privileged access, it will fail due to the following error:
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (No such file or directory)
Answer
Let’s assume I want to install JDK into /opt/JDK as user myuser (of course, I must have write privileges to /opt/JDK).
The command to do it is quite complex so check it very carefully. The trick is to use home directory *(or some other directory where user has write access) as RPM DB, TAGS, and TRANSACTION location:
$ whoami myuser $ cd /tmp; ls jdk-11.0.8_linux-x64_bin.rpm $ rpm --dbpath /home/myuser/rpm_tags/var/lib/rpm/ --nodeps --define="_rpmlock_path /home/myuser/rpm_tags/var/lib/rpm/transaction" --prefix /home/myuser/usr_tags/ -ivh jdk-11.0.8_linux-x64_bin.rpm --prefix=/opt/JDK --noscripts warning: jdk-11.0.8_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY Preparing... ################################# [100%] Updating / installing... 1:jdk-11.0.8-2000:11.0.8-ga ################################# [100%] $ /opt/JDK/jdk-11.0.8/bin/java --version java 11.0.8 2020-07-14 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)
Maybe this helps someone.
Regards,
Dusan Baljevic (amateur radio VK2COT)
Responses