Vakindu
Vakindu

Reputation: 815

Issue setting Confluent Kafka JAVA_HOME path in .bashrc with Error - no such file or directory

I am trying to set a JAVA_HOME path for my Confluent and Kafka application. I'm using confluent-6.1.0, Java 15, and Windows OS (WSL).

The confluent and Java paths are set in a '.bashrc' file. When starting the application, I run the command "source .bashrc" in the linux terminal to set the application paths.

The CONFLUENT_PATH works fine.

The issue is with the JAVA_HOME path, which keeps giving the error: "fork/exec /mnt/c/java/jdk-15/bin/java: no such file or directory".

I have confirmed multiple times that the directory defined is correct.

When I add the "java.exe" file path directly to the top of the 'kafka-run-class.sh' file in the confluent bin folder, the code seams to work fine.

JAVA_HOME=/mnt/c/java/jdk-15/bin/java.exe

But for production reasons, I want to define the path values directly inside ".bashrc".

What could be the issue? Thanks!

Here is my ".bashrc" script:


export JAVA_HOME=/mnt/c/java/jdk-15
export PATH="${JAVA_HOME}/bin:$PATH"

export CONFLUENT_HOME=/mnt/c/Windows/system32/confluent-6.1.0
export PATH="${CONFLUENT_HOME}/bin:$PATH"

Upvotes: 0

Views: 175

Answers (2)

Vakindu
Vakindu

Reputation: 815

WSL interoperability allows you to run Windows executables from Linux, but you have to include the .exe extension. On the other hand, Confluent is trying to run an executable called java instead of java.exe. This is because Confluent is not built for WSL, but for Linux.

One workaround could be to install a Linux JDK under WSL, so that you have a java executable.

Upvotes: 1

k314159
k314159

Reputation: 11212

The JAVA_PATH variable should point to the Java installation directory, and the java command should be taken as $JAVA_PATH/bin/java. However, in your Windows environment, your Java executable is called java.exe instead of just java. WSL allows to you run Windows executables but you must include the .exe extension. To allow applications to run when they use just the name java, you can add this Bash script to the Java bin directory, where java.exe lives:

#!/bin/bash
exec "$0.exe" "$@"

Name this script java, and run chmod +x java. This will create an executable script called java which will run java.exe in the same directory.

You can copy this file to whatever other executable you want to do the same to.

Upvotes: 1

Related Questions