Got a new mac. `which java` shows `/user/bin/java...
# random
c
Got a new mac.
which java
shows
/user/bin/java
but
java -version
and
javac -version
says "The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java." Why does
which java
report /user/bin/java?
h
So how does it look if you execute java using the full path?
/user/bin/java -version
? (Really? With an e in /user/?)
c
i think macos just has a java wrapper installed
i would install java with homebrew https://brew.sh
or you can also just use idea to download jdks, and use jenv to configure which one you use
j
Mind to download Java with the right architecture. Some only release with x86 This can be a huge speed difference on newer M1 based macs.
c
idea shows the jdk arch. zulu has m1 jdks
image.png
t
Another option for Java on Mac is
sdkman
, which I’ve used for a few years now and really like: https://sdkman.io/
1
c
I always have a terrible experience with sdkman. Guess that's just me though.
1
@christophsturm I used to use homebrew for adoptopenjdk but it was recently deprecated https://github.com/AdoptOpenJDK/homebrew-openjdk @hallvard I get the same response unfortunately if I type out the path directly.
c
I installed all my jdks with idea this time and it was great. and i use jenv to switch between them.
homebrew also has temurin which is not deprecated
c
I tried learning what termurin is but I've honestly never heard of it before.
I'm just trying to install azul zulu m1 mac compatible jdk. 😭
I tried sdkman and my java_home didn't work and wasn't picked up in the IDE.
I'm going to try to install my jdk from the IDE like you. lol
f
InfoQ is lately heavily advertising https://github.com/HanSolo/JDKMon, maybe it's worth something?
c
brew also has a m1 native jdk 17. but if you need older jdks i recommend zulu
jdkmon page says its unstable on m1 because of javafx. someone should port it to compose
c
How would you recommend installing zulu?
Like... I'd prefer to use homebrew
c
I installed it via idea, but theres probably a homebrew cask too.
but openjdk 17 is also m1 native https://formulae.brew.sh/formula/openjdk#default
but nothing currently works with jdk 17 🙂
f
Gradle 7.3-RC does 😉
c
Yeah. I need 11 or 14. How would https://formulae.brew.sh/cask/zulu work? After I install it, does my JAVA_HOME and everything get set automatically for me or is there still work for me to do there? (Also, just want to say thank you for all chiming in. I've setup JDKs for years now, but man it somehow is always a slight pain to get it working and I always feel like an idiot)
c
i think 11 for m1 is only available from zulu. homebrew will not set your java home, you could use jenv for that
if you just need one jdk i think homebrew will set that up correctly
f
Afaik its always setting the last that was installed as the global one. But, I can only second @christophsturm’s jEnv recommendation, it's the best choice here.
c
Never used jenv. Will take a look. Jake responded to my tweet here too. I'm going to take a look at his latest rec. https://twitter.com/JakeWharton/status/1456346029012537353