Open nauni77 opened 2 years ago
Hi @nauni77,
Thank you for the kind words, we really appreciate that.
Firstly, I'm not sure if you realise it, but SDKMAN on Mac is running in a single mode. Either Rosetta 2 is completely switched on or off. This depends on the config that you've set with sdk config
.
In your case, the config seems to be switched on. I can see this by what's printed in the header of what you pasted:
Available Java Versions for macOS 64bit
This tells me you are running with Rosetta 2 switched on. The impact that this has is that the Java list view will only show you the Intel Mac Java distributions. This is also true for any other multi platform candidates like Micronaut and JMC. If you change the config and open a new shell, you should see a different message in your header and only ARM distributions will be displayed in the list now.
I hope my explanation helped. We're always happy to answer such usage questions on Slack.
Hello, thanks for your information, this makes it much clearer. First I did not enable the Rossetta 2 option. But later (because of some problems) I enabled this.
I thought this will show additional Rossetta2-JDKs and the JDKs build native for the Chip. I didn't know that this switch all versions.
Why you decided not to make both versions available? Even with Rossetta 2 you can run JDKs build for the Mac-Chip. In general I prefere to run native Versions for Apple-Chip. But in some constelations it do not work and I need to switch. IMHO a mixed mode would be useful.
IMHO in my case I IMHO already have a mix of these. The JDKs before enable Rossetta2-Option will install the native version of this JDKs. The JDKs installed after switching will install the Rossetta2-Compatible versions.
I would like to see this as well. Combine the two lists and indicate the available java versions supported CPU architecture. The need for this is that some java libraries require JNI and load dylib that still only provide an x86 version.
So I find myself constantly switching between x86 java (for dynamic library support) and arm java (for speed as it can be 3x faster).
I believe when listing the installed versions there's no indication of the CPU architecture either, making it hard to know which of the installed versions would be running under rosetta and which would be running at full speed.
It's possible I am not understanding the current behavior, but the list does not appear to be working correctly with regards to the Rosetta config flag.
For example, if I disable the flag (to install an ARM JDK) and then install an ARM JDK, that JDK will show up in both lists (in other words, after I've re-enabled the flag and opened a new terminal window, the JDK I installed shows up as installed
on the Intel list also). As far as I can tell though, SDKMAN only installed the ARM version, not the Intel one.
I have the same use case as mvitaly; I have jni libs that are x86 and need an x86 Java. I'm setting sdkman_rosetta2_compatible
to true
but I'm still seeing Available Java Versions for macOS ARM 64bit
; I thought I would see the x86 Javas.
Hi @garfieldnate, my bad for not updating here, but I've since removed the Rosetta 2 compatibility feature.
It served its purpose well in the early days when ARM JDKs weren't available, but now we have plenty of options. However, over the last while this feature was causing a lot of confusion so I finally removed it.
Hope it makes more sense now.
@marc0der Thanks for the clarification! Maybe I should open a separate ticket for this, but what I'd actually like is a way to choose which CPU architecture to download JDK's for. In my current project I have to run x86-64 binaries, so I need an x86-64 JDK.
Sure, open a new issue with a clear description of what you need and we can look at it. Alternatively you could try hacking the ~/.sdkman/var/platform
file to see if that works.
In your case, the config seems to be switched on. I can see this by what's printed in the header of what you pasted:
Available Java Versions for macOS 64bit
This tells me you are running with Rosetta 2 switched on. The impact that this has is that the Java list view will only show you the Intel Mac Java distributions.
What banner is displayed when running in Arm mode?
@marc0der I have just the opposite problem, I cannot get arm64 version ...
Where I manually changed that .sdkman/var/platform to arm64 (dunno if that's the right value ...)
Shouldn't sdkman_rosetta2_compatible=false
make sure I get arm64?
I uninstalled / re-installed sdkman, graalce ... a few times, I still get x86_64 as os.arch
...
I am seeing the same issue i.e. I cannot see any Apple Silicon version I have a new M3 Max macbook and used migration assistant to copy all my files from my old Intel mac I have sdkman_rosetta2_compatible=false when I do "sdk list java" I see: Available Java Versions for macOS 64bit
What do I hack the ~/.sdkman/var/platform file to be? It's currently: darwinx64
I can answer my own question - the value is: darwinarm64 (I logged in as a different user and reinstalled sdkman, then looked in the file)
And then it worked for you?
On Wed, 21 Feb 2024 at 00:17, Connor Sadler @.***> wrote:
I can answer my own question - the value is: darwinarm64 (I logged in as a different user and reinstalled sdkman, then looked in the file)
— Reply to this email directly, view it on GitHub https://github.com/sdkman/sdkman-cli/issues/1092#issuecomment-1955304604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACRA6BDPOF4K4MCIUBKITLYUUVHBAVCNFSM5VR2XYG2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJVGUZTANBWGA2A . You are receiving this because you commented.Message ID: @.***>
And then it worked for you?
I changed it to darwinarm64
... still the same ...
Yes I changed that file, started a new terminal, then "sdk list java" says at the top: Available Java Versions for macOS ARM 64bit
I can then install arm versions but sdkman doesn't show you in the list which version of java is using which archtecture you can check by changing to that java version in a terminal and doing: file $JAVA_HOME/bin/java If it says "arm64" at the end then it's Apple silicon
to be clear, I now have multiple versions of Java installed, some of which are x86 (emulated) and some are arm64 (fast) and you can't tell from the list in sdkman which are which, but you can workaround it with the "file" command above
/Users/alesj/.sdkman/candidates/java/current/bin/java: Mach-O 64-bit executable x86_64
As expected ...
But is sdk install java 21.0.2-graalce
actually also available in arm64
?
Afaik, it should be ... as some of my colleagues do have it ...
I don't think you can install the same version twice What does it say at the top when you do this command? sdk list java If it says: Available Java Versions for macOS ARM 64bit then as I understand it you are now in arm64 "mode" for sdkman So any version you install will be the arm64 one
Just for an experiment, if you get this far, just choose a slightly different Java version to the one you currently use and install that, and see if it's an arm64 one
I don't think you can install the same version twice
Even if I uninstall it, remove sdkman, etc?
If it says: Available Java Versions for macOS ARM 64bit
Yeah, I do get that
just choose a slightly different Java version to the one you currently use and install that, and see if it's an arm64 one
OK, let me try that ...
sounds like you are nearly there! I would think uninstalling the old java and reinstalling would work (i.e. get you the arm version of it instead), but I haven't tried that yet myself
Ah, nice ... that worked ... 21.0.1-graalce (instead of previous 21.0.2 ...)
alesj@Skywalker quarkus % file $JAVA_HOME/bin/java
/Users/alesj/.sdkman/candidates/java/current/bin/java: Mach-O 64-bit executable arm64
I would think uninstalling the old java and reinstalling would work (i.e. get you the arm version of it instead), but I haven't tried that yet myself
Hmmm, well, I tried that ... but no luck ... so some (weird) caching must be taking place ?!
that is a shame - that's beyond my limited knowledge, sorry maybe it would need a dig through how sdkman works, or someone with more knowledge to comment
Hello, first of all thanks for this great tool!
I own a MacBook with M1-Chip. Now a lot of platforms support this architecture, but sometimes it's not possible to live without rosseta2. For example if some native bindings are used to build docker container with gradle/ java.
It is perfect that SDKMAN support to install JDKs compatible with rosseta2. This is the solution for the problem. Thanks for this!!!!
But one (IMHO small) thing needs to be enhanced. Please write the processor architecture to the list of java versions. At the moment nobody can see if this is a native build sdk or a compilation works with rosseta2:
I hope you can add a column for the processor architecture. BTW a lot of reports feel the same with this missing information.
For example: https://itnext.io/how-to-install-x86-and-arm-jdks-on-the-mac-m1-apple-silicon-using-sdkman-872a5adc050d "But it will be very helpful if there is another column that identifies the architecture of the JDKs."
Thanks in advance, Oli