I'm trying to run some code locally in a Windows machine using WSL/Ubuntu with openjdk version "21.0.2". The code reads a .jpg image, but fails specifically at this step:
ImageIO.getImageReadersByFormatName("jpg");
This line throws an Error:
java.lang.UnsatisfiedLinkError: /home/user/.sdkman/candidates/java/17.0.10-tem/lib/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
I tried to change the format name to jpeg, JPG and JPEG with the same results.
This code runs with no problems on a MacOS and a Windows physical system. It runs on Linux containers as well.
I tried to reinstall Java with no luck.
Edit: I tried already sudo apt-get install libxrender1 with no luck. Now this question is closed without any feedback on how to improve the quality of the question...
Edit 2: Writing my solution here for the ages since I was blocked from getting answers to my question witout any piece of feedback.
I found this answer with the solution:
Install libxrender1 -
sudo apt-get install libxrender1Modify the file ~/.bashrc to add:
export DISPLAY=:0 export XAUTHORITY=$HOME/.Xauthority
Run
source ~/.bashrc
That led me to another error:
java.lang.UnsatisfiedLinkError: /home/daniel-fuente/user/candidates/java/17.0.10-tem/lib/libawt_xawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
Then I found this answer that led me to the end of the solution:
apt-get install libxrender1 libxtst6 libxi6