0

When I open the Windows 10 command line and write "java -version" at the cursor, the response is: java version "1.8.0_391" Java(TM) SE Runtime Environment (build 1.8.0_391-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.391-b13, mixed mode)

However, when I use the OSGeo4W Shell command line, and type "java -version", the response is: 'java' is not recognized as an internal or external command, operable program or batch file.

When I try to use the Whitebox Tools tools for rasters, this error message appears: 'java' is not recognized as an internal or external command, operable program or batch file. Process returned error code 1

How to fix this error?

1 Answer 1

2

In your OSGeo4W window, check the value of JAVA_HOME environmental variable. This example is from my computer:

C:\OSGeo4W>set java_home
JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-11.0.21.9-hotspot\

Add bin at the end of the java directory and append that path into the OSGeo4W search path

C:\OSGeo4W>set path=%path%;C:\Program Files\Eclipse Adoptium\jdk-11.0.21.9-hotspot\bin

Now java is found.

C:\OSGeo4W>java -version
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment Temurin-11.0.21+9 (build 11.0.21+9)
OpenJDK 64-Bit Server VM Temurin-11.0.21+9 (build 11.0.21+9, mixed mode)

For making the change permanent edit the o4w_env.bat file that is located in the [OSGEO4W_ROOT]/bin directory. The line to edit is

set path=%OSGEO4W_ROOT%\bin;%WINDIR%\system32;%WINDIR%;%WINDIR%\system32\WBem

Add your java bin directory at the end of the line.

After updating OSGeo4W with the installer program, check if the bat file has been overwritten.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.