I had the same issue on a linux machine. I was quite frustrated at first, because I have installed both the JDK and JRE. I am using version 1.6, 1.7 and 1.8 simultaneously, and I have played a lot with the alternatives to have everything set properly.
The problem was quite stupid to solve, yet counter-intuitive. While I was using the correct JDK, I paid attention to the path of the tools jar maven complained about - it was expecting it to be
$JAVA_HOME\..\lib\tools.jar
The $JAVA_HOME
variable pointed directly to my jdk
folder (/usr/local/java
which was also the correct $PATH
entry and alternative sym link). It actually searches for the lib
folder outside the java directory, because:
$JAVA_HOME\..\lib\tools.jar
will resolve to
/usr/local/lib/tools.jar
and that is not a valid location.
To solve this, the $JAVA_HOME
variable should instead point to this location /usr/local/java/jre
(assuming the JDK path is /usr/local/java
) -- there is actually jre
folder inside the JDK installation directory, that comes with each JDK. This new setup will cause maven to look at the JRE directory, that is part of the JDK:
$JAVA_HOME\..\lib\tools
which now resolves to
/usr/local/java/jre/../lib/tools.jar
and finally to
/usr/local/java/lib/tools.jar
which is where the tools.jar
really resides.
So, even if you are indeed using the JDK instead of the JRE, the $JAVA_HOME has to point to the JRE. Remember, the OS alternative should still refer to the JDK.
space
in a name. I was trying to run./bin/kafka-console-consumer.sh
from the binaries kafka folder. when i was asked to build project first with./gradlew jar -PscalaVersion=2.13.6
. This build command actually generated such error for me. – Jeanettajeanette