Search code examples
javawindowsapache-kafkawindows-subsystem-for-linuxconfluent-platform

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"


Solution

  • 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.