“Unable to find bundled Java version” Flutter doctor Ubuntu fix.

Brian Mutinda
4 min readDec 28, 2022

--

You have run “flutter doctor -v” on Ubuntu and you get this error “Unable to find bundled Java version” as shown below.

Terminal screenshot of “Flutter doctor -v” command output

This error is caused because Java cannot be found within the system.If you run “java — version” on your terminal and you see something to the screenshot below it means Java cannot be located on your system.

“Java — version” command on terminal output

To locate java, your operating system has a variable called JAVA_HOME that indicates the location of java on your machine. Whenever applications require java the query the JAVA_HOME variable from the operating system which returns the path to java on your machine. You can read more about it here.

In this article I show you how I resolved the issue (unable to find bundled Java version) on Ubuntu 22.04 by setting the JAVA_HOME variable on my operating system.

Make sure you already have Android studio installed.

Lets jump in.

Step 1: Locate Android studio path

Android studio comes with a built in java, all you have to do is locate the java path in the studio files and point the operating system to that java.

One way to find where android studio is located on your machine, is to run “flutter doctor -v” and under “Android Studio” checks you should have a screenshot as shown below.

Terminal screenshot of “Flutter doctor -v” command output

From the above screenshot my Android studio is located at “/snap/android-studio-canary/35/android-studio”. Your path might be different.

Step 2: Locate Java on Android studio directory

Once you have located android studio path, java files should be located inside the android studio directory.

Copy the android studio path and on the terminal type “nautilus” followed by the android studio path. In my case it will be: “nautilus /snap/android-studio-canary/35/android-studio”.

This will open the File manager GUI as shown below.

Once there confirm that a “jbr” folder exists, this is where Java is located and this will be the path to the JAVA_HOME variable.

Get the path directory, in my case the path is “/snap/android-studio-canary/35/android-studio/jbr”.

Step 3: Set JAVA_HOME variable on Ubuntu operating system

Once you have the java path, open “/etc/profile” file to set the path to the java file using any editor (nano / vim e.t.c ) that you prefer.

At the end of the file add the following lines:
export JAVA_HOME=/snap/android-studio-canary/35/android-studio/jbr
export PATH=$PATH:$JAVA_HOME/bin

JAVA_HOME (this is the java path on step 2).

Once completed your file should look something similar to the screenshot shown below.

Step 4: Save and restart

Once you have added the lines on step 3, save your file and run this command on the terminal “source /etc/profile” to make the changes on the current shell.

It is advisable however to restart your machine to make the changes permanent.

Step 5: Test and confirm

Once you restart your machine and type “java -version”on your terminal, you should have something similar as displayed below.

This means that java is now successfully installed and you can build your flutter apps successfully.

In some cases the error “Unable to find bundled Java version” may still be present but you can still run flutter successfully on android studio.

It shouldn’t be a concern as long as you have set your java path correctly.

Happy coding.

--

--

Brian Mutinda

Flutter (mobile application) developer sharing my knowledge, expertise, life experiences and discoveries with the world through writing.