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

Development issue/problem:

I followed the official start-up step by step. I started with a clean installation of Linux and installed everything I needed according to the Build Projects tab with native code. I also read the troubleshooting section. I’ve already made a project using the terminal.

It’s a mistake if I launch a reactive android:

Running the JS server…
Build and install the application on the device (android cd && ./gradlew installDebug)……

ERROR: JAVA_HOME is not installed and the java command is not in your PATH.

Set the JAVA_HOME variable in your area to location
of your Java installation.

The application could not be installed on the device, see the error above for details.
Make sure the Android emulator is running or the device is connected and
has configured your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html.

It does not find JAVA_HOME because the current versions of Android Studio do not require Java to be installed on the system. The internal JRE is used instead.

Duplicate the disclaimer : I’ve already read this question. That’s not what I want. I know how to install Java at home. I just want to do a reactive project WITHOUT having to install a separate java.

Questions:

How can I solve this problem?

Solution 1:

I will answer my own questions and give my fellow users of Linux a sponge bath:

1- To point JAVA_HOME to the JRE in Android Studio, first locate the Android Studio installation folder and then the /jre folder. The full path to this directory is the path JAVA_PATH needs for installation (thanks to @TentenPonce for the answer).
Under Linux, you can install JAVA_HOME by adding this line to your .bashrc or .bash_profile :

output JAVA_HOME=/day

This file is the same file you added to ANDROID_HOME when you followed the React Native Getting Started for Linux program. Both are hidden by default and can be found in your home directory. After adding the string, you must restart the terminal so that it can accept the new environment variable. Then print it:

Source $HOME/.bash_profile

or

Source $HOME/.bashrc

and now you can control the Jet Run android in the same terminal. Another option is to reboot the operating system. Other terminals may work differently.

NOTE: To make the project really work, you first need to run the Android emulator or connect a real device. The easiest way is to open an existing Android Studio project and run the emulator from there, and then close Android Studio.

2… Since the reactionary run-and-cold seems to do exactly that:

android cd && ./gradlew installDebug

In fact, you can open an Android project that is nested with Android Studio and run it manually. JS modifications can be reloaded by making it possible to reload directly in the emulator. Type CTRL + M (CMD + M on macOS) and select Enable real-time restart from the menu that appears (for the Kudos – @BKO response).

Solution 2:

Windows 10 :

Android Studio -> File -> Other settings -> Default project structure… -> Locate the JDK :

For example, copy B. the indicated line:

C: Software FilesAndroidAndroid Studiojre

In the window to search for files in the folder, right-click This PC ->.

Properties -> Advanced system settings -> Ambient variables … -> Variable systems

Click on the button New…. under System Variables and then type and paste it:

……. Variable name : JAVA_HOME

……. Variable : C: Software FilesAndroidAndroid Studiojre

and press the OK button to close.

For some installations it may also be necessary to install JRE_HOME in the same way.

To test, open a new black console window and type echo %JAVA_HOME%. You must retrieve the entire path you entered in the system variable. Windows 10 seems to support the spaces in filenames for system variables well and does not seem to need to be deleted beforehand.

Solution 3:

I think the right way to find the internal java that is used in Android Studio is

  1. Open the Android studio
  2. Go to File->Other Parameters->Standard Project Structure/JDK Format :
  3. and copy the line marked there.

There is no need to remember the folder or search for java, and these steps also remove any future changes to the java localization command Changes in Android Studio, I think.

Solution 4:

It’s in the Android Studio folder itself, where you installed it.

Give here a description of the image

Solution No 5:

Add the user variable JAVA_HOME to the number of the system variable.

  1. Create a variable name like JAVA_HOME
  2. Use this format in the value field -> C:Program FilesJavajdk(version) what you have or downloaded.

Solution No 6:

I solved that problem by installing jre. I already installed jdk, but jre wasn’t installed.

Solution No 7:

All I did was go to my project directory from cmd (command line), I typed java -version.it which told me which version it was looking for. So I installed this version, and changed the path to get the jdk from this version.

Solution No 8:

I ran it from the command line (with the Windows 7 operating system):
JAVA_HOME=C:Software FilesAndroidAndroid Studiojre

are true = the path to the jre-map, so each can be different.

Solution No 9:

  1. Make sure you have Java installed
  2. Your way is wrong.

Do it. Do it:

Export | Grip JAVA

RESULTS: that Java Home has been implemented for

JAVA_HOME=Library/Java/Java Virtual Machines/Jdk1.8.0_202.jdk/Content/Content/Home

  1. Follow the path to make sure the folders are correct.

I did it in my terminal:

public library

When I went to /Java/JavaVirturalMachines
it turned out to be the wrong folder jdk1.8.0_202.jdk, there was another number…..
4. You can use this command to install java_home.

export JAVA_HOME=Library/Java/JavaVirtual Machines/jdk1.8.0_202.jdk/Content/Content/Home

Related Tags:

java path react native,could not find java in java_home,android studio java_home,cannot determine a valid java home,set java_home windows command line,java_home command not found,java_home is set to an invalid directory,install java in ubuntu,install java windows 10,jdk download,android studio,set java_home windows 10,install java jdk,ubuntu install java,android studio download,run react native app,how to set java_home path in windows,react native run-android,jdk 8,jre download,what is java_home,set java_home mac,error: java_home is not set please set it in your environment,android studio java_home is not set,java_home: command not found,please set the java_home variable in your environment to match the,warning: java_home environment variable is not set