1

I have an application which I would like to deploy, compiled for java 1.8.0_151. However, the user has only 1.8.0_25. User cannot launch the app because LocalDateStringConverter is missing.

As written here (https://docs.oracle.com/javase/8/javafx/api/javafx/util/converter/LocalDateStringConverter.html) this class has been added only in 8u40

How can I compile (is it possible?) a jar with dependencies for the specific java version of the user?

Or maybe I misunderstood something, new to java here

EDIT I tried specify the pricise version with update number in my pom.xml but it didn't help

dgan
  • 1,349
  • 1
  • 15
  • 28
  • 1
    You can use the [Maven Enforcer Plugin](https://maven.apache.org/enforcer/enforcer-rules/requireJavaVersion.html) to require a specific Java version – Mincong Huang Mar 20 '18 at 17:59
  • The best option to handle such things is to use maven-enforcer-plugin which already mentioned by @MincongHuang – khmarbaise Mar 20 '18 at 18:16

2 Answers2

1

There are a two ways to approach this:

  • You have to set your environment to use the JDK that is expected by the user. In this case 1.8.0_25 - you need to develop all logic using this JDK and the classes available in it. If LocalDateStringConverter is your only dependency missing, you can easily find out the source code and duplicate the logic inside your project as utility class and use that instead.

  • You can ask/help/advise your user to upgrade their environment to more recent JDK version (security reasons and such). As you are aware most software has minimum requirements to run and it's expected from the end user to meet those requirements in order to run the software.

As already mentioned you can use the Maven Enforcer Plugin to enforce specific java version, but this will not make the functionality from 1.8.0_151 available in 1.8.0_25.

hovanessyan
  • 30,580
  • 6
  • 55
  • 83
0

Compiling your code with 1.8.0_25 and hoping that the newer versions are backward compatible is probably the easiest solution. Assuming you have automated tests this will catch problems like a missing class.

The other option would be to build an executable bundle containing both your application and the entire JRE 1.8.0_40 or newer. This is going to result in your software bundle growing by dozens of MBs so I would not recommend it. However one way to do it would be to use Launch4j as advised here.

You can try implementing your own LocalDateStringConverter but how many other classes are you missing? What if there are other subtleties in behaviour between versions? Based on java.com 1.8.0_25 was released on October 14, 2014 while 1.8.0_151 on October 17, 2017. That's 3 years of Java development that your user is missing.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111