Mac The operation couldn’t be completed. Unable to locate a Java Runtime that supports jarsigner
Asked Answered
C

3

33

My purpose is to use jarsigner to sign apk.

I get the following prompt:

% jarsigner     
The operation couldn’t be completed. Unable to locate a Java Runtime that supports jarsigner.
Please visit http://www.java.com for information on installing Java.

my java version hint:

% java -version
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)

Mac version is 11.6.3

How can I solve this problem please?

Curling answered 10/2, 2022 at 2:57 Comment(5)
I use (and recommend) SDKMAN to manage my Java environments.Catnap
I think you installed jre instead of jdkMoneychanger
Or the environment variables are incorrectly configured. The jarsigner is in JAVA_HOME/bin.Moneychanger
my jarsigner location is here % whereis jarsigner /usr/bin/jarsignerCurling
How to determine if jdk is installed?Curling
C
20

I finally solved it by downloading the JDK

Curling answered 10/2, 2022 at 4:34 Comment(2)
I used this link to avoid having to create an account with oracle but this worked for me too. oracle.com/java/technologies/downloads/#jdk18-macRadiance
Do I need to do something more to make it work? I have installed it but it doesn't work? Should I deactivate the virtual environment? ThanksJarrell
C
71

Mac users, follow the below steps:

  1. brew install openjdk@11
    
  2. For the system Java wrappers to find this JDK, symlink it with:
    sudo ln -sfn $(brew --prefix)/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
    

Reference: https://formulae.brew.sh/formula/openjdk@11

This approach will also work for other versions.

Cheesecloth answered 23/9, 2022 at 1:51 Comment(3)
You shouldn't need to symlink. Most programs respect JAVA_HOME env-varSchreiber
It's an alternate way to point Java to correct JDK. For me, first time setup with brew required me to execute symlink. Second scenario, in case you have multiple Java JDK, symlink to switch to correct JDK also works.Cheesecloth
symlink command needed in MacOSVouge
C
20

I finally solved it by downloading the JDK

Curling answered 10/2, 2022 at 4:34 Comment(2)
I used this link to avoid having to create an account with oracle but this worked for me too. oracle.com/java/technologies/downloads/#jdk18-macRadiance
Do I need to do something more to make it work? I have installed it but it doesn't work? Should I deactivate the virtual environment? ThanksJarrell
G
4

You need to check jdk version which installed to our system. This example is for mac os with m1.

Enter in your terminal:

java -version

Output:

openjdk version "1.8.0_372"
OpenJDK Runtime Environment (Zulu 8.70.0.23-CA-macos-aarch64) (build 1.8.0_372-b07)
OpenJDK 64-Bit Server VM (Zulu 8.70.0.23-CA-macos-aarch64) (build 25.372-b07, mixed mode)

Then input the commands:

  1. sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

  2. echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc or ~/.bashrc

  3. export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"

It worked for me

Gallon answered 23/7, 2023 at 9:36 Comment(2)
I did the same thing ans still I have same errorAristotelianism
This actually worked, and now Xcode is happy to build the Kotlin Multiplatform project.Nucleotidase

© 2022 - 2024 — McMap. All rights reserved.