Configure Java in Arch Linux to run a React Native application

Arch linux Aug 8, 2018

Building applications with React Native on Linux and macOS usually need some extra configuration like setting environment variables that sometimes is not clear about where or how to put them.

Right now I am using Arch Linux in my second computer, so I decided to configure it to develop a React Native application. I installed everything and by the time I run the app with:

react-native run-android

I got some errors regarding the version of the Java, the environment variable and some others, so in order to run your app correctly you must follow these steps:

  • Install sudo pacman -S jdk8-openjdk because with Java 10 I couldn’t run the app.
  • Add JAVA_HOME to your .bash_profile file export JAVA_HOME=/usr/lib/jvm/default
  • List your Java environments with archlinux-java status
  • Set a default Java environment with archlinux-java set [java-8-openjdk] or the one printed in the previous command
  • Finally source ~/.bash_profile

With those simple steps you will be able to run your react-native application on Arch Linux!