How to check JRE version prior to launch?

You could do this using reflection and two compilers. Compile a main class with the oldest java version you want to be able to run at all with. It checks the version using System.getProperty("java.version"), or whatever, and then uses reflection to load your real main class if that check passes, possibly even loading the jar directly. The JRE shouldn’t load any classes that weren’t referenced by your outer main class at compile time.

Leave a Comment