I had the same problem in Ubuntu/Mint 20.04 when using OpenJDK 17.
I found out that with OpenJDK 11 works well.
Key elements to consider:
# Have version 11 installed
sudo apt install openjdk-11-jdk
# Update alternatives to use version 11 as default
sudo update-alternatives --config java
# Set the JAVA_HOME environment variable accordingly
export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64