Fixing "not found: java" Mock API endpoint error
Tags: beginners, aws, amplify
Published: 2019-12-19 20:13:02

TL;DR: **Download the Java SDK, then manually add the path to your environment variables.**

------------------------------

"My middle name is Edge Case," I joked, my hand the only one raised in a room of about 100 people. At that moment, I was the only person still unable to get `amplify mock api` to work on the command line. 

The problem? No java:

![Screenshot of Git Bash CLI with red message "Failed to start API Mock endpoint Error: not found: java"](https://thepracticaldev.s3.amazonaws.com/i/0xk5wa1kqjs64tm2rjxv.png)
Easy fix. I found what I thought would be the right `npm` package and blithely hit `Enter`. 

I got back a wall of error messages, mostly having to do with `gyp` missing `Python`:

![Screenshot of Git Bash CLI with multiple "gyp ERR! find Python" error messages and instructions for installing Python](https://thepracticaldev.s3.amazonaws.com/i/lq8cwidykk9tae7dea3w.png)

Thankfully, somebody nearby was having a similar issue and had just solved it by downloading the [Java SDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk13-downloads-5672538.html) directly from Oracle.

I grabbed the Windows version, installed it, and ran `amplify mock api` again. Again, it told me I had no java.

I went into Programs and checked. There it was, happily ensconced between Internet Explorer (huh?) and Killer Networking (uhm... huh?).

Maybe it was telling me I needed more coffee? I tried that. No luck.

![Photo of two coffee dispensers both labeled "Breakfast Blend"](https://thepracticaldev.s3.amazonaws.com/i/q6j5x3ayhjcixgaqe3dz.jpg)

But then something clicked. I remembered similar issue I'd ran into during boot camp (the only Windows 10 user in my class). The solution then was to manually enter the path into Environment Variables.

To try that, I went to the Control Panel\System and Security\System and clicked on [Advanced system settings](https://www.isumsoft.com/it/5-methods-to-open-windows-10-system-properties-advanced/).

![Screenshot of Windows Control Panel with the link to Advanced system settings highlighted in blue](https://thepracticaldev.s3.amazonaws.com/i/dhwce1yn32ahx43c9qch.png)

In the System Properties/Advanced panel that opened, I clicked on Environment Variables.

![Screenshot of the System Properties/Advanced panel with the Environment Variables button highlighted in blue](https://thepracticaldev.s3.amazonaws.com/i/jrf9y9cx5uji2ckq5lyl.png)

That took me to the panel with `User` and `System` variables, both including the option to add a new `Path`.

![Screenshot of the System Variables panel with Path highlighted in gray for User variables and blue for System](https://thepracticaldev.s3.amazonaws.com/i/211b38fanc1r7vh1lyhk.png)

I first selected the User variables `Path` and clicked on `Edit`. That took me to the Edit environment variable panel with an option to add a new `Path`.

![Screenshot of the Edit environment variable panel with New button and an empty row under existing paths highlighted in blue](https://thepracticaldev.s3.amazonaws.com/i/t7tg1dwbyzqcujag47ru.png)

To make sure I entered the path correctly, I used the File Explorer to navigate into the `bin` folder for `Java`, then right clicked on the address to copy it.

![Screenshot of a File Explorer window opened to the bin folder inside the Java folder, with the option to copy the address highlighted](https://thepracticaldev.s3.amazonaws.com/i/fphaoxrh2af1kjx4fwig.png)

I copied and pasted it into both `User` and `System` Path variables, and clicked `OK`.

![Screenshot of the Edit environment variable panel with the copied address pasted into the row under existing paths and the OK button highlighted in blue](https://thepracticaldev.s3.amazonaws.com/i/3xgs9w19d1galeihik3h.png)

After that, I kept clicking `OK` until I was out of the Control Panel. Then, for the changes to register with the CLI, I had to close and reopen it again. Finally, I ran `amplify mock api` one more time...

![](https://thepracticaldev.s3.amazonaws.com/i/1s06735pndys6r6ia4u6.png)

It worked!

And so, at long last, I could carry on with the workshop, [building real-time offline-ready applications with React, GraphQL & AWS AppSync](https://github.com/dabit3/aws-appsync-react-workshop).