Issue with Java and win 11

Hi,
On a new laptop, I download and install the msi file for microsoft java.

I try oracle java initially, but the version was too low. I then try Graal, but had the same error as below. I finally decide to try microsoft, since they had an msi.

I can echo the Java_Home variable and I can retrieve the java version from my typedb directory, yet running typedb server results in the error that Java is not installed. Why?

typedb.bat contains the following code that validates the existence of Java on your machine:

where java >NUL 2>NUL
if %ERRORLEVEL% GEQ 1 (
    echo Java is not installed on this machine.
    echo TypeDB needs Java 11+ in order to run. See the following setup guide: http://docs.vaticle.com/docs/get-started/setup-guide
    pause
    exit 1
)

Firstly we should diagnose the error. Try running the following two commands in your terminal:

where java
echo %ERRORLEVEL%

When I run this locally, I get:

> where java
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
> echo %ERRORLEVEL%
0

thanks alex,

I am running on the Anaconda prompt, not command.com or git bash. then i get the following results
Maybe its the error level because i cannot even run scripts within the vs code terminal?

OK, so your terminal can’t find the where utility that (to the best of my knowledge) comes preinstalled with all modern Windows systems.

It should be located at %WINDIR%\System32\where.exe. (WINDIR is normally C:\Windows, so it would be C:\Windows\System32\where.exe.) Can you check that this file exists?

If it doesn’t exist then we’ll need to figure out why; if it does exist, then that implies C:\Windows\system32 is missing from your PATH (or perhaps your Anaconda prompt doesn’t have access to PATH?) which we can verify with

echo %PATH%

ok, the plot thickens.

I have the where executable in my system32 directory, and it doesn’t seem to have privileges

Running the echo on the path gives

Given it is a new windows 11 system, it may be that there is some kind of advanced security, or maybe its a path issue? what do you think?

I note that on the terminal window for vs code, i get the following security issue about running scripts is disabled on this device?

I note that on the terminal window for vs code, i get the following security issue about running scripts is disabled on this device?

PowerShell disables scripts on most Windows systems by default, actually, as a security measure. The linked article from go.microsoft.com in the error message explains why, and how to set up your execution policy to enable running .ps1 scripts that you trust.

Given it is a new windows 11 system, it may be that there is some kind of advanced security, or maybe its a path issue? what do you think?

There’s definitely a problem with your PATH environment variable.

Every Windows system should have C:\Windows\system32 in its PATH, but yours doesn’t. This is needed to get system utilities to run (such as where.exe).

I notice one suspicious thing: your path contains the string ;%PATH;. It looks like, at some point, some script has tried to construct the PATH environment variable by appending values to the existing value of PATH. Something like:

SET PATH=C:\Program Files\Microsoft\jdk-17.0.3.7-hotspot\bin;%PATH

But this script has a critical bug; it should read

SET PATH=C:\Program Files\Microsoft\jdk-17.0.3.7-hotspot\bin;%PATH%

%PATH% resolves to the value of the environment variable PATH. %PATH resolves to just the literal string “%PATH”.

I wonder if the Microsoft JDK installer has a bug - or if you’ve ever entered a command similar to the above to try to append to the system PATH?

I would suggest that this is something that is addressed ASAP, as it will cause many programs to break unexpectedly! One possible approach is to attempt to restore the PATH variable to a previous state (see eg:

You should take a backup copy of your existing PATH before doing any of the above. The paths such as the Anaconda paths, you will likely want to re-append to your PATH after the restore.

1 Like

thanks @alex
I will get into changing the path tomorrow, but i am sure you are on the right track.

For your info, the PAth is split into two, both user and system path, and it is the system path that has the repeat variable, so it looks like this

so i think the system path, just adds in the user account path, but i show each panel below.

first the user account path looks like

then the system path looks like

I will add the additional path elements tomorrow, lets hope that adding system32 to the path fixes the problem

Woo Hoo @alex , you are the genius.

It turns out adding system32 to the user account path was the missing link. Once i did this, then TypeDB started without any problems.

Thanks for your help

1 Like