tofi86 / universalJavaApplicationStub

universalJavaApplicationStub - an alternative Application launcher script for Java based macOS Apps that works with both Apple's and Oracle's PList format and supports the old Apple Java 6 as well as all the latest Oracle/OpenJDK/Adopt/Corretto JRE's/JDK's. Plus it supports drag&drop to the Dock icon 🎉
MIT License
356 stars 168 forks source link

Priority to the Oracle JRE #34

Closed ebourg closed 8 years ago

ebourg commented 8 years ago

Hi,

I'd like to suggest this change to use the Oracle JRE in priority over the other runtimes. I have a Java application requiring Java > 6 and the launcher always picks the old Apple JRE even if a more recent Oracle JRE is available. This is annoying because I can't increase the version of Java required for my application until I notice a significant drop in Java 6 usage on OS X, and if the Oracle JRE doesn't have the priority it never happens.

tofi86 commented 8 years ago

Phew... This is a hard decision... Using the Oracle JRE path has always been a hack. A good one, I know, since forcing users to install the JDK is always hard—but making it the first choice when searching for a specific version?—I'm not sure about it yet...

ebourg commented 8 years ago

Well, considering that Apple is no longer updating its JRE I think it's a good idea to prefer the Oracle one, at least for security reasons.

tofi86 commented 8 years ago

The path which is currently checked first (/usr/libexec/java_home/) is not "the old apple JRE" path. It's the system hub for all registered java versions. So this is the first point one would look for java installations on the system. And it has a native interface for checking for a specific java version. that's why I'm using it with highest priority at the moment.

Unfortunately Oracle fucked it up and they didn't make the JRE (plugin) register itself in this hub, but only the JDK version.

Anyways – if you're requiring Java > 6 (which means 1.7+ in the JVMVersion Plist key, right?) the old java 6 installation should not be picked up at all, or am I wrong?

What's the output of this command on your system /usr/libexec/java_home -V and what's the value of your JVMVersion Plist key? Which Java version is used then and what would you expect? Can you give this as an example, please?

ebourg commented 8 years ago

Sorry for the confusion, I meant Java >= 6.

Maybe a better approach would be to find all the Java runtime available and satisfying the version required in the plist file, and then picking the one with the highest Java version.

tofi86 commented 8 years ago

Okay, Java >= 6 is a valid point...

Maybe a better approach would be to find all the Java runtime available and satisfying the version required in the plist file, and then picking the one with the highest Java version.

That's a great idea! I would prefer to implement this rather than merging these changes here... Agree?

ebourg commented 8 years ago

I would prefer to implement this rather than merging these changes here... Agree?

Sure, but I'm not sure I'll be able to implement this in a shell script. I guess we have to scan all the known JRE locations without stopping on the first one found, keep the latest JRE found and its version in a pair of variables, and update them if a more recent version is found later in the scan.

tofi86 commented 8 years ago

I will have a look for next version 1.1