2

I installed Java 17 version with asdf and it works without any problems in a Java project:

➜  ~ asdf list java
  adoptopenjdk-17.0.0+35

But when checking the java version with java -version in the terminal, it displays the following errors:

~ java -version
/Users/xxx/.asdf/shims/java: line 3: /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf: No such file or directory
/Users/xxx/.asdf/shims/java: line 3: exec: /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf: cannot execute: No such file or directory

I'm using Oh My Zsh terminal and the following line:

. /opt/homebrew/opt/asdf/libexec/asdf.sh

added after installation o asdf is the last one in the .zshrc file.

What's wrong with that? Thank you.

belgoros
  • 3,590
  • 7
  • 38
  • 76

2 Answers2

7

This solved the issue for me:

  1. rename the ~/.asdf/shims directory
  2. run asdf reshim

More details.

jfhector
  • 103
  • 1
  • 6
  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 03 '22 at 02:01
  • Can use rm -rf ~/.asdf/shims – GregP Nov 16 '22 at 19:49
  • Thank you ! `asdf reshim` was enough for me. – Luboš Hájek Feb 04 '23 at 09:05
  • zsh: permission denied: /Users/xxx/.asdf/shims when doing first step – compski Feb 06 '23 at 15:26
2

Try

asdf global java adoptopenjdk-17.0.0+35

asdf reshim

It sets adoptopenjdk-17.0.0+35 as default for the user and then asdf will update the shims.

Akkadaya
  • 21
  • 3