# SCIFIO java version limitations

**URL:** https://discourse.itk.org/t/scifio-java-version-limitations/2383
**Category:** Engineering
**Created:** [November 6, 2019, 2:22pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383 "2019-11-06T14:22:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [November 6, 2019, 2:22pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/1 "2019-11-06T14:22:44Z")

</div>

After an upgrade to Debian-10 (Buster) we can no longer process image formats with ITK that need SCIFIO (bioformats). Even though ITK-5.0.1 is newly compiled after the upgrade we get:

```auto
File: /opt/compilation/ITK_build/Modules/Remote/SCIFIO/src/itkSCIFIOImageIO.cxx
Line: 180
Description: itk::ERROR: SCIFIOImageIO(0x561739001e10): SCIFIOImageIO exited abnormally. Exception in thread "main" java.lang.UnsupportedClassVersionError: io/scif/itk/SCIFIOITKBridge : Unsupported major.minor version 52.0

```

The installed JRE/JDK is OpenJDK-11 and is the only one so far supported by Debian for Buster.  
52.0 howerver seems to correspond to Java-8.

So I wonder if the JARs for SCIFIO are not compiled locally but downloaded?  
How to solve this problem?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [November 6, 2019, 5:25pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/2 "2019-11-06T17:25:46Z")

</div>

There is an [outstanding issue](https://github.com/scifio/scifio-imageio/issues/55) to update the bundled JVM.

We could also update the JARs. Chatting with @ctrueden, my understanding that we can now move to bioformats JARs, which are maintained and now available in a non-copyleft license.

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [November 7, 2019, 11:59am UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/3 "2019-11-07T11:59:31Z")

</div>

Tried to solve this issue temporarily with a docker image based on ubuntu16:04 with openjdk-8 ([https://github.com/romangrothausmann/ITK-CLIs/commit/e6e720f667f57f8cbad8216ec864583ba9687664](https://github.com/romangrothausmann/ITK-CLIs/commit/e6e720f667f57f8cbad8216ec864583ba9687664)) but am getting the same error even with the resulting docker image ([registry.gitlab.com/romangrothausmann/itk-clis/scifio](http://registry.gitlab.com/romangrothausmann/itk-clis/scifio)). Would I be needing more than just openjdk-8-jre in the docker execution environment?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 7, 2019, 3:23pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/4 "2019-11-07T15:23:19Z")

</div>

I have been using SCIFIO will out issue recently on OSX and Linux in several environments. I installed `openjdk-8-jdk` on an ubuntu 18.04 image recently to get it working.

You may also find some insights in a recent SimpleITK Conda recipe where I enabled SCIFIO to create a local package.

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [November 7, 2019, 3:53pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/5 "2019-11-07T15:53:55Z")

</div>

Hm, what java dependencies need to be satisfied during built and which during execution time? For my setup in the Dockerfile compilation works without any problems even without any JDK or JRE. With SCIFIO enabled, the installation then contains JARs and even a folder named jre/, so one might think it would not even need a JRE from the system.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 7, 2019, 4:47pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/6 "2019-11-07T16:47:54Z")

</div>

I was able to build and test ITK with SCIFIO as follows on a debain:buster docker image:

```auto
apt install build-essential ninja-build cmake-curses-gui openjdk-11-jdk
git clone https://github.com/InsightSoftwareConsortium/ITK.git
mkdir bld && cd bld
ccmake -G Ninja -DModule_SCIFIO=ON ../
ninja
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::")
ctest -V -R ITKSCIFIOImageInfoTest0

```

Setting `JAVA_HOME` overrides the old JAVA version downloaded as part of SCIFIO.

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [November 7, 2019, 5:30pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/7 "2019-11-07T17:30:04Z")

</div>

Many thanks @blowekamp for the hint with `JAVA_HOME`, that did the trick even for the local installation.  
So is the error caused because the “old JAVA version downloaded as part of SCIFIO” does not match the version of javac that was used to compile the SCIFIO-JARs (also downloaded as part of SCIFIO?)?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 7, 2019, 5:55pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/8 "2019-11-07T17:55:35Z")

</div>

> [@grothausmann.roman](#):
>
> So is the error caused because the “old JAVA version downloaded as part of SCIFIO” does not match the version of javac that was used to compile the SCIFIO-JARs (also downloaded as part of SCIFIO?)?

Yes, the JVM downloaded take priority over `java` in the PATH, but JAVA\_HOME take higher priority. If you just delete `lib/jre` from the build tree and provide a java it works too.

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [November 8, 2019, 12:12pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/9 "2019-11-08T12:12:49Z")

</div>

Also got it working within a docker image with specifying JAVA\_HOME

> <https://github.com/romangrothausmann/ITK-CLIs/commit/1a9705180b230f98baefb53eefd944b5714927c8>

  
pointing to openjdk-8-jre or even openjdk-11-jre.  
So the prolem seems to be due to the SCIFIO JARs being built for a different java version than is provided by `lib/jre` in the ITK installation.  
With

```auto
JAR=/opt/itk-5.0.1/lib/jars/scifio-itk-bridge.jar ; unzip -p $JAR `unzip -l $JAR | grep '\.class$' | awk 'NR==1 {print $4}'` | file -

```

I get `compiled Java class data, version 52.0 (Java 1.8)` but

```auto
/opt/itk-5.0.1/lib/jre/bin/java -version

```

reports `java version "1.6.0_24"`. Since SCIFIO works even if there is no java/javac available when ITK is compiled ([https://github.com/romangrothausmann/ITK-CLIs/blob/1a9705180b230f98baefb53eefd944b5714927c8/Dockerfile](https://github.com/romangrothausmann/ITK-CLIs/blob/1a9705180b230f98baefb53eefd944b5714927c8/Dockerfile)), I conclude that the SCIFIO JARs are not compiled when ITK is compiled but instead are pulled (pre-compiled) from the net. Is that right?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [November 8, 2019, 1:19pm UTC](https://discourse.itk.org/t/scifio-java-version-limitations/2383/10 "2019-11-08T13:19:20Z")

</div>

> [@grothausmann.roman](#):
>
> SCIFIO JARs are not compiled when ITK is compiled but instead are pulled (pre-compiled) from the net.

That is right.
