Closed johnjelinek closed 3 years ago
I ended up getting it to work by copying some files from package asdf-java
downloaded:
> "$PWD"
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents
> ls -lahR
total 8
drwxr-xr-x@ 5 root wheel 160B Dec 12 16:22 .
drwxr-xr-x@ 3 root wheel 96B Dec 12 16:17 ..
lrwxr-xr-x 1 root wheel 59B Dec 12 16:22 Home -> $HOME/.asdf/installs/java/amazon-corretto-8.232.09.1
-rw-r--r--@ 1 root wheel 1.5K Dec 12 16:17 Info.plist
drwxr-xr-x@ 3 root wheel 96B Dec 12 16:26 MacOS
./MacOS:
total 0
drwxr-xr-x@ 3 root wheel 96B Dec 12 16:26 .
drwxr-xr-x@ 5 root wheel 160B Dec 12 16:22 ..
lrwxr-xr-x 1 root wheel 32B Dec 12 16:26 libjli.dylib -> ../Home/jre/lib/jli/libjli.dylib
Now this works:
> /usr/libexec/java_home --verbose
Matching Java Virtual Machines (1):
1.8.0_232, x86_64: "Amazon Corretto 8" /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
and I can filter on jdk version:
/usr/libexec/java_home -v 1.8
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
@johnjelinek I like the idea of making asdf-java more compatible with the way MacOS works. Would one need root privileges to write symlinks to these locations? If that's accurate, how would you propose handling that?
PRs welcome!
Yes, it'll require . sudo
to do the symlink. Does asdf
offer the ability to accept a password when sudo
is needed, like homebrew
does?
I don't know, also MacOS is not an easy platform for me to test on - is this something you could look into?
Any news on this? I am willing to help with the PR if there is still interest in adding such functionality.
It should be a matter of copying the files to correct location and a symlink like @johnjelinek pointed out.
The only caveat would be testing if the sudo password is properly asked when trying to install and inform to the user why is it needed.
MacOS has a convention of using
/usr/libexec/java_home
to list installed JVMs/JDKs. Instead of overwritingJAVA_HOME
, can we make use of/usr/libexec/java_home
instead? Perhaps a symlink can be added in here:/Library/Java/JavaVirtualMachines/
.