How to make pdfsam work in (L)ubuntu 18.04?

I have the following versions of OpenJDK installed:

java-1.11.0-openjdk-amd64      1101       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64

I get the following error using PDFsam in Lubuntu 18.04:

INFO   [12:15:47]: Starting PDFsam
INFO   [12:15:48]: Transparent windows not supported by the platform
INFO   [12:15:48]: Configuring Sejda 3.2.38
INFO   [12:15:48]: Gestarted in 1 second
INFO   [12:15:57]: 3.pdf loaded
INFO   [12:15:57]: 4.pdf loaded
INFO   [12:15:57]: 5.pdf loaded
INFO   [12:15:58]: Starting task (org.sejda.impl.sambox.MergeTask@81b1817) execution.
WARN   [12:15:59]: New fonts found, font cache will be re-built
WARN   [12:15:59]: Building on-disk font cache, this may take a while
ERROR  [12:15:59]: Unexpected error
java.lang.NoClassDefFoundError: Could not initialize class org.sejda.sambox.pdmodel.font.PDType1Font
at org.sejda.impl.sambox.util.FontUtils.<clinit>(FontUtils.java:74)
at org.sejda.impl.sambox.component.PDDocumentHandler.close(PDDocumentHandler.java:231)
at org.sejda.common.ComponentsUtility.nullSafeClose(ComponentsUtility.java:63)
at org.sejda.common.ComponentsUtility.nullSafeCloseQuietly(ComponentsUtility.java:49)
at org.sejda.impl.sambox.MergeTask.closeResources(MergeTask.java:232)
at org.sejda.impl.sambox.MergeTask.after(MergeTask.java:237)
at org.sejda.core.service.DefaultTaskExecutionService.actualExecution(DefaultTaskExecutionService.java:151)
at org.sejda.core.service.DefaultTaskExecutionService.execute(DefaultTaskExecutionService.java:71)
at org.sejda.core.service.DefaultTaskExecutionService.execute(DefaultTaskExecutionService.java:58)
at org.pdfsam.task.TaskExecutionController.lambda$request$0(TaskExecutionController.java:87)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

It is known bug bug 1768565 on the LaunchPad about broken compatibility between OpenJDK 11 and PDFSaM Ubuntu package.

I found working solution. We should remove pdfsam Ubuntu-package and download pdfsam-basic from official site:

sudo apt-get purge pdfsam
sudo apt-get autoremove
cd ~/Downloads
wget https://github.com/torakiki/pdfsam/releases/download/v4.0.1/pdfsam_4.0.1-1_all.deb
sudo apt-get install ./pdfsam_4.0.1-1_all.deb

This is not first time, as Scilab was broken by Java too (see this Q&A).
So Ubuntu 18.04 LTS is not yet ready for enterprise and educational deployment.


Solution is here:

https://bugs.launchpad.net/ubuntu/+source/pdfsam/+bug/1768565

The bug is fixed in Ubuntu 18.04 (Bionic Beaver 64 bit) once the default java version is set to java-8. No need to downgrade or uninstall java-10 or java-11. The default java is java-11 for Ubuntu 18.04. PDFSAM basic 3.35 or 3.37 is written in java-8 and will work with java-8 only.

Tested on PDFSAM Split and Merge Basic Edition 3.3.5 OpenJDK Runtime Environment 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13

Run in terminal sudo update-alternatives --config java

Select/type 2 (or whatever serial number is shown against java-8). The press Enter to set the default java version to java-8.