# Issue with Java and win 11

**URL:** <https://forum.typedb.com/t/issue-with-java-and-win-11/158>\
**Category:** TypeDB\
**Created:** [19 July 2022 05:34 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158 "2022-07-19T05:34:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![modeller](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@modeller](https://forum.typedb.com/u/modeller)\
**Post date:** [19 July 2022 05:34 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/1 "2022-07-19T05:34:05Z")

</div>

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?

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/5688e52cd037f127d0bf5844453d538fc4b3ca1c.png)

---

<div class="post-metadata">

**Author:** ![alex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/alex/32/148_2.png) [@alex](https://forum.typedb.com/u/alex)\
**Post date:** [19 July 2022 09:12 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/2 "2022-07-19T09:12:41Z")

</div>

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

```auto
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:

```auto
where java
echo %ERRORLEVEL%

```

When I run this locally, I get:

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

```

---

<div class="post-metadata">

**Author:** ![modeller](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@modeller](https://forum.typedb.com/u/modeller)\
**Post date:** [19 July 2022 09:18 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/3 "2022-07-19T09:18:52Z")

</div>

> [@alex](#):
>
> `echo %ERRORLEVEL%`

thanks alex,

I am running on the Anaconda prompt, not [command.com](http://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?

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/6c020f0f1c1c8476bb038b18b67d208da1a5f160.png)

---

<div class="post-metadata">

**Author:** ![alex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/alex/32/148_2.png) [@alex](https://forum.typedb.com/u/alex)\
**Post date:** [19 July 2022 09:38 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/4 "2022-07-19T09:38:04Z")

</div>

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

```auto
echo %PATH%

```

---

<div class="post-metadata">

**Author:** ![modeller](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@modeller](https://forum.typedb.com/u/modeller)\
**Post date:** [19 July 2022 09:50 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/5 "2022-07-19T09:50:02Z")

</div>

ok, the plot thickens.

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

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/e7c46a23ffd5c50c02d8b9800859a5f048f7d7c5.png)

Running the echo on the path gives

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/8e77b521dca57b18737bb7b97f6b1ff157263efc.png)

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?

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/06fb941b5dcf333d03616be4795768b6fb6a223b.png)

---

<div class="post-metadata">

**Author:** ![alex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/alex/32/148_2.png) [@alex](https://forum.typedb.com/u/alex)\
**Post date:** [19 July 2022 11:23 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/6 "2022-07-19T11:23:00Z")

</div>

> 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:

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

```

But this script has a critical bug; it should read

```auto
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:

- [windows - How to restore the Path environment variable I deleted? - Super User](https://superuser.com/questions/523688/how-to-restore-the-path-environment-variable-i-deleted),
- [windows 8 - I overwrote my environment variable PATH - Super User](https://superuser.com/questions/676695/i-overwrote-my-environment-variable-path)

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.

---

<div class="post-metadata">

**Author:** ![modeller](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@modeller](https://forum.typedb.com/u/modeller)\
**Post date:** [19 July 2022 11:50 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/7 "2022-07-19T11:50:55Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/8781e79c5fde35419b2a1382d5ae569323ea8846.png)

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

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/f74f9496f01b6d7fed38b5929187de0c41464e0d.png)

then the system path looks like

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/47a83f99612ed61a00402b31ac3701424450c2bf.png)

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

---

<div class="post-metadata">

**Author:** ![modeller](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@modeller](https://forum.typedb.com/u/modeller)\
**Post date:** [20 July 2022 02:27 UTC](https://forum.typedb.com/t/issue-with-java-and-win-11/158/8 "2022-07-20T02:27:44Z")

</div>

> [@alex](#):
>
> %WINDIR%\System32

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.

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/vaticle/original/1X/030cbccd9d553ce72aa404359aedd3877535133a.png)

Thanks for your help
