Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix this? JavaFX - Wrong JPEG library version: library is 80, caller expects 70

Tags:

libjpeg

javafx

I get this error whenever I try to create an Image in JavaFX. Absolutely no images are loading, but everything else on the UI is. The only time I see this is when prism.verbose=true

Other answers to similiar questions here on StackOverflow suggest reinstalling libjpeg. But when I do sudo apt-get remove libjpeg8, it tries to remove 4 GB worth of packages that seem pretty dang important.

Has anyone else experienced this and found a feasible solution that isn't going to require me to reinstall my entire OS?

Here is the entire stacktrace:

java.io.IOException: Wrong JPEG library version: library is 80, caller expects 70
at com.sun.javafx.iio.jpeg.JPEGImageLoader.initDecompressor(Native Method)
at com.sun.javafx.iio.jpeg.JPEGImageLoader.<init>(JPEGImageLoader.java:187)
at com.sun.javafx.iio.jpeg.JPEGImageLoaderFactory.createImageLoader(JPEGImageLoaderFactory.java:49)
at com.sun.javafx.iio.ImageStorage.getLoaderBySignature(ImageStorage.java:419)
at com.sun.javafx.iio.ImageStorage.loadAll(ImageStorage.java:266)
at com.sun.javafx.tk.quantum.PrismImageLoader2.loadAll(PrismImageLoader2.java:142)
at com.sun.javafx.tk.quantum.PrismImageLoader2.<init>(PrismImageLoader2.java:77)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.processStream(PrismImageLoader2.java:252)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.processStream(PrismImageLoader2.java:225)
at com.sun.javafx.runtime.async.AbstractRemoteResource.call(AbstractRemoteResource.java:109)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.access$201(PrismImageLoader2.java:225)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.lambda$call$428(PrismImageLoader2.java:259)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.call(PrismImageLoader2.java:258)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.call(PrismImageLoader2.java:225)
at com.sun.javafx.runtime.async.AbstractAsyncOperation.lambda$new$272(AbstractAsyncOperation.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

And this is my version info for java. I'm using the Oracle version.

java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

EDIT:

I ran strace on my app and it looks like something is searching specifically for libjpeg 8 only. It's not ever trying to look for any default libjpeg library or libjpeg 7 at all.

like image 908
arjabbar Avatar asked Feb 24 '16 15:02

arjabbar


2 Answers

A possible workaround is to not let JPEGImageLoader decode the jpegs but rather do it with ImageIO instead. You lose some of the built-in features of the javafx Image only available via constructor parameters such as smooth, preserveRatio, backgroundLoading but at least it is safer on linux.

Something like this might work for you:

import java.awt.image.BufferedImage;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;

public static Image createImage(File file) throws IOException {
    BufferedImage bufferedImage = ImageIO.read(file);
    WritableImage writableImage = SwingFXUtils.toFXImage(bufferedImage, null);
    if (writableImage.isError()) {
        throw new RuntimeException(writableImage.getException());
    }
    return writableImage;
}
like image 129
Johan Tidén Avatar answered Oct 07 '22 01:10

Johan Tidén


I think that Java is linked against libjpeg7, but you might have libjpeg8 in your LD_LIBRARY_PATH, so the interface does not match.

libjpeg.so comes with Java (in the lib/amd64 folder for x64 systems), but this is not beeing used probably due to an override in your LD_LIBRARY_PATH.

like image 33
Edvin Syse Avatar answered Oct 07 '22 00:10

Edvin Syse