React Native: Java_Home Is Not Set and No 'Java' Command Could Be Found in Your Path

React Native: JAVA_HOME is not set and no 'java' command could be found in your PATH

I'll answer my own questions and sponfeed my fellow linux users:

1- To point JAVA_HOME to the JRE included with Android Studio first locate the Android Studio installation folder, then find the /jre directory. That directory's full path is what you need to set JAVA_PATH to (thanks to @TentenPonce for his answer).
On linux, you can set JAVA_HOME by adding this line to your .bashrc or .bash_profile files:

export JAVA_HOME=<Your Android Studio path here>/jre

This file (one or the other) is the same as the one you added ANDROID_HOME to if you were following the React Native Getting Started for Linux. Both are hidden by default and can be found in your home directory. After adding the line you need to reload the terminal so that it can pick up the new environment variable. So type:

source $HOME/.bash_profile

or

source $HOME/.bashrc

and now you can run react-native run-android in that same terminal. Another option is to restart the OS. Other terminals might work differently.

NOTE: for the project to actually run, you need to start an Android emulator in advance, or have a real device connected. The easiest way is to open an already existing Android Studio project and launch the emulator from there, then close Android Studio.

2- Since what react-native run-android appears to do is just this:

cd android && ./gradlew installDebug

You can actually open the nested android project with Android Studio and run it manually. JS changes can be reloaded if you enable live reload in the emulator. Type CTRL + M (CMD + M on MacOS) and select the "Enable live reload" option in the menu that appears (Kudos to @BKO for his answer)

Cmd/React Native can't detect my JAVA_HOME environment variables

According to react native document, you should install just JDK 8 for running react native app

https://facebook.github.io/react-native/docs/getting-started

after installing java and set the environment variable, you must reboot your system.

https://www.thewindowsclub.com/set-java_home-in-windows-10

Android Studio , on windows : JAVA_HOME is not set and no 'java' command could be found in your PATH

I understood your problem, add your JDK (Not JRE) path to the PATH variable in environment variables. Then run the java command, and it should run. And whenever you post a question, please do make sure that you mention details like what happens when you run java command :)

JAVA_HOME is not set error, after running React-native app

First Add the JDK and JRE paths to the System Variable "Path"
like below:
Sample Image

Secondly, Add the JAVA JDK path to the USER variable as JAVA_HOME. as shown below:
Sample Image

Restart the cmd and go to the app directory and run the app with react-native run-android
Voila:
Sample Image

React Native and Flutter Installation Invalid JAVA_HOME directory on Windows 10

In the development environment setup document of React Native, the solution for this error that occurs in Windows is not presented.
https://reactnative.dev/docs/environment-setup

Solution suggestion 1: I solved this error as follows. Instead of JDK, it is necessary to add the JRE file path to JAVA_HOME environment variables.

Correct environment variable value

Solution suggestion 2: System Image files specified in the document did not work for my processor. If solution suggestion 1 did not resolve your error, try to find the System Image file suitable for your processor.

Good luck.



Related Topics



Leave a reply



Submit