skiptools / skip

Skip transpiler for creating SwiftUI apps for iOS and Android

Home Page:https://skip.tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java version: error executing java

lennarthakker opened this issue · comments

When running skip checkup --verbose I'm getting the following error on checking the java version:

Java version: error executing java
executing command: /usr/local/bin/adb version
Android Debug Bridge version 1.0.41
Version 35.0.0-11411520
Installed as /usr/local/bin/adb

Any idea on how to resolve this error?

Using a m1 mac already made sure that the terminal isn't running on Rosetta.

I'm guessing that maybe you have an older version of Java in your PATH.

Try the following commands and let us know the output. I've included my own machine's values for comparison:

zap ~ % java -version

openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment Homebrew (build 21.0.2)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.2, mixed mode, sharing)

zap ~ % which java

/opt/homebrew/bin/java

zap ~ % echo $JAVA_HOME

<nothing>

zap ~ % brew list openjdk

/opt/homebrew/Cellar/openjdk/21.0.2/bin/jar
/opt/homebrew/Cellar/openjdk/21.0.2/bin/jarsigner
/opt/homebrew/Cellar/openjdk/21.0.2/bin/java
/opt/homebrew/Cellar/openjdk/21.0.2/bin/javac
… etc …
/opt/homebrew/Cellar/openjdk/21.0.2/include/ (8 files)
/opt/homebrew/Cellar/openjdk/21.0.2/libexec/openjdk.jdk/ (531 files)
/opt/homebrew/Cellar/openjdk/21.0.2/share/man/ (28 files)

Also maybe try running brew reinstall skip openjdk and then let us know the output of skip doctor.

This is the result of the terminal

openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment Homebrew (build 21.0.2)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.2, mixed mode, sharing)

zap ~ % which java

/usr/local/opt/openjdk/bin/java

zap ~ % echo $JAVA_HOME

<nothing>

zap ~ % brew list openjdk

/usr/local/Cellar/openjdk/21.0.2/bin/jar
/usr/local/Cellar/openjdk/21.0.2/bin/jarsigner
/usr/local/Cellar/openjdk/21.0.2/bin/java
/usr/local/Cellar/openjdk/21.0.2/bin/javac
/usr/local/Cellar/openjdk/21.0.2/bin/javadoc
/usr/local/Cellar/openjdk/21.0.2/bin/javap
/usr/local/Cellar/openjdk/21.0.2/bin/jcmd
/usr/local/Cellar/openjdk/21.0.2/bin/jconsole
/usr/local/Cellar/openjdk/21.0.2/bin/jdb
/usr/local/Cellar/openjdk/21.0.2/bin/jdeprscan
/usr/local/Cellar/openjdk/21.0.2/bin/jdeps
/usr/local/Cellar/openjdk/21.0.2/bin/jfr
/usr/local/Cellar/openjdk/21.0.2/bin/jhsdb
/usr/local/Cellar/openjdk/21.0.2/bin/jimage
/usr/local/Cellar/openjdk/21.0.2/bin/jinfo
/usr/local/Cellar/openjdk/21.0.2/bin/jlink
/usr/local/Cellar/openjdk/21.0.2/bin/jmap
/usr/local/Cellar/openjdk/21.0.2/bin/jmod
/usr/local/Cellar/openjdk/21.0.2/bin/jpackage
/usr/local/Cellar/openjdk/21.0.2/bin/jps
/usr/local/Cellar/openjdk/21.0.2/bin/jrunscript
/usr/local/Cellar/openjdk/21.0.2/bin/jshell
/usr/local/Cellar/openjdk/21.0.2/bin/jstack
/usr/local/Cellar/openjdk/21.0.2/bin/jstat
/usr/local/Cellar/openjdk/21.0.2/bin/jstatd
/usr/local/Cellar/openjdk/21.0.2/bin/jwebserver
/usr/local/Cellar/openjdk/21.0.2/bin/keytool
/usr/local/Cellar/openjdk/21.0.2/bin/rmiregistry
/usr/local/Cellar/openjdk/21.0.2/bin/serialver
/usr/local/Cellar/openjdk/21.0.2/include/ (8 files)
/usr/local/Cellar/openjdk/21.0.2/libexec/openjdk.jdk/ (531 files)
/usr/local/Cellar/openjdk/21.0.2/share/man/ (28 files)```

skip doctor results: 
[✓] Skip version 0.8.25 (= 0.8.25)
[✓] macOS version 14.3.1 (> 13.5.0)
[✓] Swift version 5.10 (> 5.9.0)
[✓] Xcode version 15.3 (> 15.0.0)
[✓] Xcode tools SDKs: 6
[✓] Homebrew version 4.2.15 (> 4.1.0)
[✓] Gradle version 8.7 (> 8.6.0)
[✗] Java version: error executing java
[✓] Android Debug Bridge version 1.0.41 (> 1.0.40)
[✓] Android Studio version: 2023.2
[✓] Android tools SDKs: 2
[✓] Check Skip Updates: 0.8.25
[✗] Skip 0.8.25 doctor failed with 1 error

zap ~ % which java

/usr/local/opt/openjdk/bin/java

That's your problem – that is the old Intel location for Homebrew apps, and so the java version you are running is the Intel version (which should, in theory, work – but there are a bunch of known issues). I'm guessing you migrated your MacBook from an old Intel to an M1 at some point in the past, and it kept the previous Homebrew install at /usr/local/opt/. You want /opt/homebrew/ for all your Homebrew stuff with the ARM macs.

I don't know the official solution, but I'd suggest removing /usr/local/opt/ altogether (stashing a backup somewhere) and installing Homebrew fresh. And check your ~/.bashrc / ~/.bash_profile and/or ~/.zshrc to clear out any references to the old /usr/local/opt/ paths.

Let us know if that helps. We'd like to add an FAQ entry for this, so any further feedback and insight you can provide will be useful to all our users, since a few have already struggled with this issue.

This did the trick. I think it was installed on the intel brew directory because of my terminal was at some point running in rosetta when installing brew.

Thanks for your help.

Great! Let us know if you encounter any other issues.