HanSolo / javafinder

JavaFinder is a little tool that helps you finding all installed Java versions in a given path
Apache License 2.0
16 stars 0 forks source link

Add support for older Linux instances #6

Closed ajshastri closed 10 months ago

ajshastri commented 10 months ago

Hello, I was trying this out on older OSes like RHEL 5 and RHEL 6, and I noticed this would not work on those OSes.

I was attempting to identify where and found that Finder.java on line 74 is coded to use the shell on /usr/bin/sh which doesn't exist on older RHEL-based OSes. Shell is in /bin/sh, the same as Alpine and MACOS. private static final String[] LINUX_JAVA_HOME_CMDS = { "/usr/bin/sh", "-c", "echo $JAVA_HOME" };

I was wondering if the Linux shell should also be referencing /bin/sh as newer OSes like RHEL 8, RHEL 9, Ubuntu 22.04, 23.10, have /bin/sh.

Perhaps this is a better idea for now?

If that doesn't work, perhaps a new File("/usr/bin/sh").exists() to default to /bin/sh is an alternative?

HanSolo commented 10 months ago

That should be easy to fix, will take a look tomorrow. Thanks for the report 👍🏻

HanSolo commented 10 months ago

Should be fixed with version 17.0.37

ajshastri commented 10 months ago

Will test it out soon after the holidays. Thank you very much!