Use multiple JDKS for different versions of React Native

Spread the love

As the stable release of react native is bumped to 0.73, it brings a lot of changes, most notable of them being new AGP and Java versions (Source)

This can cause an issue if your older projects use JDK 11 and the one instantiated with 0.73 uses JDK 17 So to use multiple JDKs at once, there are the following methods (Decreasing order of menial work required).

Modify the JAVA_HOME variable every time you switch projects.

This can be done by updating environment variables,

Setting the path of JDK on a per-project basis

In , specify the path to a specific jdk folder by setting the variable

The only downside is if multiple people are working on the project, they would have to change it to their local path

SDKMAN (Recommended)

Just like nvm, SDKMAN is a tool for managing various versions of Java dependencies

Install on Bash on Windows using

Clear the JAVA_HOME Variable so that sdkman can configure it

To switch versions, end all tasks which are using java & use sdk default command