halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
454 stars 86 forks source link

.asdfrc for macOS java_home not working #149

Open ColtonIdle opened 3 years ago

ColtonIdle commented 3 years ago

I created the asdfrc file and added that key value pair

Proof

coltonidle@MacBook-Air ~ % cat ~/.asdfrc 
java_macos_integration_enable = yes

coltonidle@MacBook-Air ~ %

Running java_home or /usr/libexec/java_home greets me with this error

coltonidle@MacBook-Air ~ % /usr/libexec/java_home
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

I'm on a brand new m1 macbook where I just installed zulu. echo $JAVA_HOME shows /Users/coltonidle/.asdf/installs/java/zulu-11.48.21/zulu-11.jdk/Contents/Home

Am I doing something wrong?

Drfloo commented 3 years ago

Hello there !

I had encounter the same issue recently.

java_macos_integration_enable is used when you're installing the version of java that you need.

Try to reinstall and tell me if it's working :)

ColtonIdle commented 3 years ago

@Drfloo Try to reinstall java? Or asdf?

Drfloo commented 3 years ago

The asdf package for java. ( zulu. ... for you i think )

asdf uninstall asdf install

ColtonIdle commented 3 years ago

Alright... idk if this is what you meant @Drfloo (sorry I'm still new to asdf)

but I ran asdf uninstall java then asdf install java and now running /usr/libexec/java_home shows /Library/Java/JavaVirtualMachines/zulu-11.48.21/Contents/Home Hooray!

Drfloo commented 3 years ago

So it's working now ? great !

Sorry my previous response was uncompleted : asdf uninstall java asdf install java

To resume it wasn't working before because you create the .asdfrc AFTER installing your package. You need to do this before installing.

robertwt7 commented 1 day ago

this also happened to me. apparently you need to add the asdfrc before installing and I didn't know that! Probably the readme of that part should be around the installation.