How to fix jlink does not exist?
Asked Answered
A

14

19

i am working with react native and am trying to use expo in a bare project but whenever i try to run the app with the command npm run android, i get this error :

Execution failed for task ':expo-modules-core:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':expo-modules-core:androidJdkImage'.
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: /home/dukizwe/Android/Sdk/platforms/android-31/core-for-system-modules.jar.
         > jlink executable /usr/lib/jvm/java-14-openjdk-amd64/bin/jlink does not exist.

I am using the linux OS, Android studio and JDK are correctly installed.

Inside /usr/lib/jvm/ folder, the structure look like this:

  • java-1.11.0-openjdk-amd64
  • java-1.14.0-openjdk-amd64
  • java-11-openjdk-amd64
  • java-14-openjdk-amd64
  • jdk-18

i don't know why it's looking in the java-14-openjdk-amd64 folder because in that folder there's no jlink executable.

In android studio the SDK Location si pointed to java-11-openjdk. Any help please ?

Arista answered 25/7, 2022 at 9:51 Comment(4)
If the Java 14 version is not there for you, I expect that you have installed JRE package for Java 14; e.g. openjdk-14-jre rather than openjdk-14-jdk. Use find to see if can find jlink in the /usr/jvm tree.Gingrich
Looks like somewhere in the project the path of jlink has been specified to be java-14-openjdk-amd64 folder. You should try searching for this path and correcting it.Barytes
jlink is only available in java-11-openjdk-amd64 folder. Where exaclty can i change this path in android folder ? I searched everywhere but not find thisArista
For OpenSuse: sudo zypper in java-17-openjdk java-17-openjdk-headless java-17-openjdk-devel (The one missing was -devel). Swap the version 17 with what you needTheatrician
S
21

I also faced same issue when I did run my React Native app on my new Ubuntu 22.x machine. I fixed it with installing JRE along with JDK.

Step 1 sudo apt install default-jre followed by java -version

should display -

Output openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2) OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2, mixed mode, sharing)

Followed by - sudo apt install default-jdk

Check - javac -version to get output as -

Output javac 11.0.14

Hope it helps!

Somnus answered 28/3, 2023 at 3:16 Comment(3)
Thanks. This worked for me. I'm using JAVA 11.0.19.Chrysarobin
worked for me, thanks a lot! I didn't have a compiler setup, fresh install. New to Java. Much appreciated @pjoshi!Choanocyte
4 weeks !! 4 Weeks .... and your response save my life !! THANK YOUAssumptive
B
14

You need to install the development package for Java. On debian, this is the openjdk-11-jdk package.

Bias answered 27/10, 2022 at 2:11 Comment(0)
S
9

It appears that you need to set the JAVA_HOME environment variable to the parent of the jlink binary. Android Studio includes its own jlink binary. On Linux (or Mac) you can use:

export JAVA_HOME="$HOME/android-studio/jbr"

what comes after $HOME would depend on where you have Android Studio installed.

a more permanent solution is to edit your ~/.bashrc file, append the command provided above (with the path modifications if any) to the end of the said file and save changes. All done, open a new terminal and try compiling again.

On Windows you need to add the JAVA_HOME to your path

Shew answered 14/8, 2023 at 1:10 Comment(0)
B
5

For IntelliJ IDEA, go to: File > Project Structure and in Project tab change SDK to any SDK that uses JDK 11 or 8.

Bourne answered 7/1, 2023 at 13:48 Comment(0)
B
3

I've just copied jlink, javac and jmod from this path:

/home/USER/android-studio/jre/bin/

to the following path:

/usr/lib/jvm/java-11-openjdk-11.0.15.0.10-1.fc36.x86_64/bin

Note: It's important to use Terminal as root

OS Used: Linux Fedora 36

Brigitta answered 28/7, 2022 at 0:44 Comment(4)
Don't copy files like this! You need to install the development package for your Java version (in my case it's Java17 on Fedora 36): sudo dnf install java-17-openjdk-develCourtyard
thanks i instaled the devel package and it is more praticalBrigitta
Am also using Fedora. Most of my mobile projects are Cordova based and I don't have this issue on those, but hit it when I tried a new project out with Capacitor instead. The solution provided by @Courtyard worked like a charm. In this instance, since I have to use Java 11 for Cordova on the same development box, Capacitor was trying to use jlink on Java 11, so I went with sudo dnf install java-11-openjdk-devel. After that I was able to npx cap run android, the point where I was previously getting the jlink does not exist error.Hermanhermann
Confirm this worked for me. Besides jlink I also had to copy a couple of other files. I'm limited to an older Ubuntu machine where installing the openjdk stuff properly was not an option, so this worked fine!Sarette
D
3

I had the same error, I've installed java-17-openjdk on Fedora it turns out that I also need to install java-17-openjdk-devel.

sudo dnf install java-17-openjdk java-17-openjdk-devel
Dispirited answered 3/7, 2023 at 16:48 Comment(0)
M
3

This work for me you can try this out clean the gradlew then run this command ....

sudo apt install openjdk-11-jdk-headless   
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
Multifold answered 12/9, 2023 at 7:32 Comment(0)
Y
2

In my case, JDK was missing for Java 17. I installed it using sudo pacman -Syu jdk17-openjdk, and it worked.

You probably do not have JDK installed. You can install it from your distro's repository. For Arch Linux, check this doc.

Yettie answered 19/7, 2023 at 13:51 Comment(0)
C
1

I upgrade from Gradle 7 to 8 and I had to also upgrade android Gradle plugin to 8.0.0, My jvmTarget was equal to 1.8 and JavaVersion.VERSION_1_8 was being used for target and source compatability

But after upgrading to gradle 8, It requires Java version to be atleast 17, I tried setting only source compatability but that didn't work, so I had to change all three, source, target & jvmTarget to 17

My application worked fine on Desktop (jvmMain), But on Android I would get jlink executable doesn't exist. Since Its kotlin multiplatform.

What didn't work

  • Downloading Coretto 17 and using that

  • Removing all sdks in project structure and using only jdk 17 from jbr

  • using jvmToolchain(17) in kotlin block inside android block

  • invalidateCachesAndRestart plus deleting the .idea folder

What worked

  • Using Android JDK, I removed all jdks in project structure -> sdks, Then added android jdk found in the jbr folder of android studio installation

  • also selected this jdk in project structure -> project -> Sdk field

  • You must also change the jdk in File -> Settings -> BuildTools -> Gradle

So It appears that the problem is that jbr jdk relly is missing the jlink executable since Android Studio jdk is working fine. I am going to redownload the jbr 17 sdk and I am pretty sure it should work , and should contain jlink executable, I think during updates somehow jlink executable got deleted.

Cadal answered 4/9, 2023 at 11:54 Comment(0)
I
0

In my gradle file I had:

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlin {
        jvmToolchain(8)
    }

Setting the same java version for compileOptions and kotlin closures fixed the issue:

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlin {
        jvmToolchain(8)
    }
Idomeneus answered 17/7, 2023 at 16:58 Comment(0)
D
0

I tried to build react native app using OpenJdk 17 but didnt work. I was getting continuous error as below

* What went wrong:

Execution failed for task ':app:compileReleaseJavaWithJavac'.

Could not resolve all files for configuration ':app:androidJdkImage'. Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.

  > Execution failed for JdkImageTransform: /home/neeraj/Android/Sdk/platforms/android-33/core-for-system-modules.jar.
     > jlink executable /usr/lib/jvm/java-17-openjdk-17.0.8.0.7-1.fc39.x86_64/bin/jlink does not exist.

I installed OpenJdk 11 and this fixed my problem. I have OpenJdk 17 also installed on my machine which I switch as and when needed.

I am using fedora 39.

Donne answered 20/11, 2023 at 15:24 Comment(0)
E
0

If you are on Manjaro or Archlinux, you have to copy jlink from the default-runtime(/usr/lib/jvm/default-runtime) to the Java 17 runtime(/usr/lib/jvm/java-17-openjdk) or your active runtime. You have to be root for you to do this. You can run this in your terminal.

cp /usr/lib/jvm/default-runtime/bin/jlink /usr/lib/jvm/java-17-openjdk/bin

You can check your active runtime using archlinux-java status.

Edibles answered 7/12, 2023 at 17:23 Comment(0)
S
0

This solution works for me:

  1. sudo apt install default-jre
  2. sudo apt install default-jdk
  3. java --version
  4. cd android && ./gradlew clean
  5. npx react-native run-android && npm start
Sectarian answered 8/1 at 7:32 Comment(0)
F
0

my case was a little different os: ubuntu
problem:

jlink executable /usr/lib/jvm/java-19-openjdk-amd64/bin/jlink does not exist.
javac executable /usr/lib/jvm/java-19-openjdk-amd64/bin/javac does not exist.
jmod executable /usr/lib/jvm/java-19-openjdk-amd64/bin/jmod does not exist.

how to solve:

sudo cp  /usr/lib/jvm/default-java/bin/jlink /usr/lib/jvm/java-19-openjdk-amd64/bin
sudo cp  /usr/lib/jvm/default-java/bin/jmod /usr/lib/jvm/java-19-openjdk-amd64/bin
sudo cp  /usr/lib/jvm/default-java/bin/javac /usr/lib/jvm/java-19-openjdk-amd64/bin
Faust answered 26/4 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.