Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java JDK 11 Breaking Old Jars/Programs

It is to my understanding that Java JREs are backwards compatible, if you write a program in Java (JDK) 7, it will run with Java (JRE) 8.

I have a couple of programs I developed in Java 8, and have .jar and EXE files that I built when I finished them, and they always ran fine. However, after installing Java JDK 11 (11.0.2), these old .jar files break...

  • A couple of them still run, but their GUIs have expanded, with buttons and images being bigger than before, and in some cases blurry
  • One program just doesn't run at all, trying to run it in a console gives an exception: "Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/activation/ActivationDataFlavor"

I understand that this class and some other javax classes have been removed from JDK 11, so from a development standpoint you couldn't use them anymore without a tool such as Maven. But I do not understand why installing JDK 11 has any effect on my old jars, as I didn't install a new JRE, and even if one came with it, it should be backwards compatible?

Too add to this, I use Apache NetBeans 10, it worked fine with Java 8, but after I installed JDK 11, NetBeans 10 still ran but its loading window was big and blurry, and the IDE's images are blurry, and all the text is bigger.

So why is installing JDK 11 having these negative effects on older programs?

Note - I have tried associating the jars/EXEs with javaw.exe from JRE version 8 (201), however, they all still have the same issues.

like image 867
Danjo Avatar asked Jan 30 '19 11:01

Danjo


2 Answers

Java tries to be backward compatible but sometimes breaking changes are necessary to evolve the ecosystem. Until now breaking changes were shipped with major release e.g. Java 9, 10, 11. In your case you are most likely affected by Java 11's JEP 320: Remove the Java EE and CORBA Modules.

Remember that Java 8 was released in 2014. For 5 years Oracle and the Java community provided patches and security fixes for Java 8 but doing this forever is impossible.

like image 151
Karol Dowbecki Avatar answered Oct 01 '22 15:10

Karol Dowbecki


The issue you are facing is likely not an incompatiblity w.r.t. the bytecode. It is just a missing class.

Java 11 dropped the support of some old technologies - for example Java Applets. If you run a Java 8 Applet in a Java 11 JDK / JRE you will get a ClassNotFound exception just because Java 11 does not provide the class / jar.

Similarly for JavaFX, which still exists, but is not longer part of the Java Distribution. You have to add it as a separate Jar.

I believe it would be possible to add these classes to a project. Personally I would like to see a port.

like image 22
Christian Fries Avatar answered Oct 01 '22 14:10

Christian Fries