1

I am trying to get firebase emulators running on my PC. No problems with functions, hosting, extensions emulators that seem to start by default. But when I enable firestore emulator via "firebase init emulators" selector menu, then running firebase emulators:start, I get "Error: Could not spawn java -version. Please make sure Java is installed and on your system PATH."

I have tried installing JDK20 https://www.oracle.com/java/technologies/downloads/#jdk20-windows and whatever java thing this is https://www.java.com/en/download/manual.jsp. I also tried dl and extracting the open source version here, https://jdk.java.net/20/. not sure if there's more to installation than extraction?

I also tried the suggestions from these threads

Firestore/Firebase Emulator Not Running - rerunning firebase init, firebase emulators:start:firestore, - lots of permutations on this. Running with firestore both installed and not installed in project. And tried running it from both my functions folder and my root firebase folder (extensions, frontend, functions, firebase.json, firestore.rules)

Java error when trying to run firebase emulators - setting PATH variable to my JDK20 installation, also tried setting PATH to my openJDK20 intallation

I also tried npm install java, before and after installing JDK. That gave me an error: npm ERR! code 1 npm ERR! path C:\Users\Kucha\Desktop\moralisAuthExtension\frontend\node_modules\java npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild

any ideas? Thank you!

kuchannn
  • 11
  • 2

1 Answers1

1

The RTDB, Firestore, Pubsub and Storage emulators require Java to run locally.

sudo apt install default-jre is for linux systems and you seem to be running on Windows (from the linked StackOverflow question).

The thing you want to satisfy to ensure java is installed is when you run java -version you'll get a version number instead of an error. The firebase CLI checks the java version before continuing, see this link: https://cs.opensource.google/firebase-sdk/firebase-tools/+/master:src/emulator/commandUtils.ts;drc=0ed8abf0d31efb100a16443f5cbd8328f932801c;l=478

Visit https://www.oracle.com/java/technologies/downloads/#jdk20-windows and download/run the exe variant.

Adding java to your environment variables can be done with this step, taken from the following website.

Right-click My Computer, then click Properties, then Advanced System Settings, then Environment Variables. Go to the Path system variable entry, and press Edit. You may see a rather long list here. At the very end, add the following:

C:\Program Files\Java\jdk1.7.0_21\bin

Note that you'll need to adjust the exact path depending on your installation location.

https://qualitestgroup.com/insights/technical-hub/how-to-add-java-to-your-system-path/

Chris
  • 846
  • 6
  • 16