How to Set Up Java JDK for Flutter and Android Studio

By Techmithu

Introduction

If you want to build Android apps with Flutter, you need Java on your computer. Flutter does not use Java to write your app. Your app is written in Dart. Java is needed by the build tools that turn your Flutter code into an Android app. Those tools are Gradle and the Android Gradle Plugin, and they run on Java. Without a working Java Development Kit, which is called a JDK, your first Flutter build will fail with a confusing error.

This guide explains how to set up Java JDK for Flutter and Android Studio on Windows 11, step by step, in simple English. It is written for a complete beginner. You do not need any Java knowledge. You only need a Windows 11 laptop with Flutter and Android Studio already installed.

By the end of this guide, you will know what a JDK is, which version to use, how to install it, how to set the JAVA_HOME variable, and how to check that everything works with flutter doctor. Follow the steps in order, and your Flutter Android builds will work the first time.

What You Will Learn

  • What Java JDK is and why Flutter and Android Studio need it
  • Which JDK version to use for Flutter in 2026
  • How to use the JDK that already comes with Android Studio
  • How to download and install a JDK yourself, for free
  • How to set JAVA_HOME and add Java to the Path on Windows 11
  • How to check your Java setup with java -version and flutter doctor
  • How to point Flutter to a specific JDK with one command
  • How to fix the most common Java and JDK errors in Flutter


Beginner student setting up Java JDK for Flutter on a laptop with Android Studio


What Is Java JDK and Why Flutter Needs It

A JDK is a Java Development Kit. It is a free software package that contains everything needed to run and build Java programs. It has the Java compiler, which is called javac, and the Java runtime, which is called java. When you install a JDK, your computer can run Java programs and build Java based projects.

Flutter needs a JDK for one clear reason. When you build a Flutter app for Android, Flutter hands the Android part of your app to Gradle. Gradle is the build tool for Android. Gradle itself is written in Java, so it needs a JDK to run. The Android Gradle Plugin, which connects Gradle to the Android SDK, also needs Java. If no JDK is found, Gradle cannot start, and the build stops before it even begins.

Here is the good news. Most beginners never need to install Java separately. Android Studio comes with its own JDK built in. It is called the bundled JDK, and Flutter uses it by default. That means many students already have a working JDK on their computer without knowing it. The problems start only when the bundled JDK is missing, when it is the wrong version, or when Flutter is told to use a different JDK that is not set up correctly. This guide covers both paths, so you can use the bundled JDK or install your own.

The key point to remember: you need a JDK because Gradle needs Java to build your Android app. You do not need to learn Java to use Flutter. The JDK works in the background, and you only set it up once.

Which JDK Version Should You Use in 2026

Java has many versions, and this confuses beginners. The simple rule is to use a version that your tools support. For Flutter in 2026, the safe choices are JDK 17 and JDK 21. Here is the full picture, checked on 18 November 2026.

JDK versionWhat it isShould you use it for Flutter?
JDK 17Long term support release, the minimum for modern Android Gradle PluginYes, the safest and most compatible choice
JDK 21Long term support release, bundled with Android Studio since LadybugYes, works with Gradle 8.5 or higher
JDK 25Latest long term support release, released 16 September 2025, latest update 25.0.5.0.3 on 24 October 2026Yes, but only with Gradle 9.1 or higher
JDK 27Latest release, released 15 September 2026, not a long term support releaseNo, too new for most Flutter projects
JDK 8 or JDK 11Old versions from past yearsNo, too old for modern Android tools

A long term support release, called LTS, gets security updates and bug fixes for many years. A version without LTS gets updates for only six months. That is why JDK 17, JDK 21, and JDK 25 are good choices, and JDK 27 is not a good choice for a beginner. JDK 27 will be replaced by JDK 28 in March 2027, and most Flutter projects are not tested with it yet.

Techmithu recommends JDK 17 for beginners. It is the minimum version that modern Android tools need, so it works with almost every Flutter project and every Gradle version from 7.3 upward. If you already use Android Studio, its bundled JDK is also a fine choice. You do not need the newest Java version to build Flutter apps. You need a version that matches your Gradle version.

One more fact to know. The next long term support release after JDK 25 is Java 29, expected in September 2027. Until then, JDK 25 stays the latest LTS. You do not need to wait for it, and you do not need to upgrade every time a new Java version appears.

Method 1: Use the JDK That Comes with Android Studio

This is the easiest method, and it is the one Techmithu recommends first. Android Studio already includes a JDK, so you may not need to download anything at all.

Step 1: Check that Android Studio is installed

Open Android Studio from the Start menu. If it opens normally, you have Android Studio. If you have not installed it yet, read the Techmithu guide How to Install Flutter and Android Studio on Windows 11 first, then come back to this guide.

Step 2: Find the bundled JDK location

Android Studio keeps its bundled JDK inside its own install folder. On Windows 11, the usual location is:

C:\Program Files\Android\Android Studio\jbr

In older versions of Android Studio, the folder was called jre instead of jbr. Both names mean the same thing here. Open File Explorer, go to that path, and check that the folder exists. Inside it, you should see a bin folder with java.exe and javac.exe. If those files are there, the bundled JDK is ready.

Step 3: Check the bundled JDK version in Android Studio

You can also see which JDK Android Studio uses from inside the program:

  1. Open Android Studio.
  2. Go to File, then Settings.
  3. On the left side, open Build, Execution, Deployment, then Build Tools, then Gradle.
  4. Look at the Gradle JDK dropdown. It shows the JDK that Android Studio uses for builds.

The current stable version of Android Studio, checked on 18 November 2026, is Android Studio Rabbit 2, version 2026.2.2 Patch 1, released on 5 November 2026. It bundles its own JDK, and Flutter uses that JDK by default when you build from Android Studio. You do not need to change anything in this dropdown unless you have a reason to use a different JDK.

Step 4: Let Flutter use the bundled JDK

When you run flutter doctor in a terminal, Flutter checks the JDK it can find. If Android Studio is installed and its bundled JDK is in place, Flutter normally finds it on its own. You do not need to set JAVA_HOME for this to work. If flutter doctor shows a green checkmark next to Android Studio and Android toolchain, your JDK setup is already done. Skip to the verification section at the end of this guide to confirm it.

When Method 1 is enough: for most students, the bundled JDK is enough. Use it, and do not install a second JDK unless you have a clear reason. Two JDKs on one computer cause more confusion than they solve.

Method 2: Download and Install a JDK Yourself

Use this method if you do not have Android Studio, if you want a specific JDK version, or if a project needs a JDK that Android Studio does not bundle. You will download a free JDK, install it, and then tell Windows where it is.

Step 1: Choose where to download Java from

There are two safe and free sources for a JDK. Download only from these official pages, never from a random download site.

  • Eclipse Temurin by Adoptium: go to adoptium.net. Temurin is a free and open source build of OpenJDK. It asks for no account and no payment.
  • Oracle JDK: go to oracle.com and open the Java Downloads page. Oracle JDK 25 is free to use under the Oracle No-Fee Terms and Conditions until September 2028. Its support runs until September 2030.

For a beginner, Temurin is the simpler choice because it is free with no licence questions. Oracle JDK 25 is also fine and is the latest LTS release.

Step 2: Pick the right download

On the download page, choose these options:

  1. Version: JDK 17 for the safest Flutter setup, or JDK 25 if you want the latest long term support release. Do not pick JDK 27 for Flutter.
  2. Operating system: Windows.
  3. Architecture: x64, for a normal 64 bit Windows laptop.
  4. File type: the .msi installer for Windows. The .msi installer is the easiest option because it sets up the files for you.

If you choose Temurin, the file name looks like OpenJDK17U-jdk_x64_windows_hotspot_17.0.x_x.msi. The exact numbers at the end change with each update, so do not worry if your file name is slightly different. It is the same JDK 17.

Step 3: Run the installer

  1. Double click the downloaded .msi file.
  2. Click Next on the welcome screen.
  3. On the Custom Setup screen, make sure the option to set JAVA_HOME is turned on. In the Temurin installer, this option is called Set JAVA_HOME variable. In the Oracle installer, the same option may be called Set JAVA_HOME variable as well. Turn it on, because it saves you a manual step later.
  4. Click Next, then Install.
  5. Wait for the installer to finish, then click Finish.

The JDK is normally installed in a folder like this:

C:\Program Files\Eclipse Adoptium\jdk-17.0.x

or, for Oracle JDK:

C:\Program Files\Java\jdk-17

The exact folder name depends on the version you installed. Remember this path, because you need it in the next section.


Downloading the Java JDK installer on a laptop


Step 4: Check that the install worked

Open a new Command Prompt and type this command, then press Enter:

java -version

If Java is installed correctly, you will see a few lines that show the version, for example java version 17.0.x. If you see a message that java is not recognized, the Path is not set yet. That is normal, and the next section fixes it.

How to Set JAVA_HOME on Windows 11

JAVA_HOME is an environment variable. It is a setting that tells Windows and your tools where the JDK is installed. Many tools, including Gradle and Flutter, look for JAVA_HOME when they need Java. Setting it correctly fixes a large number of build errors.

Step 1: Open Environment Variables

  1. Press the Windows key and type environment variables.
  2. Click Edit the system environment variables. A System Properties window opens.
  3. Click the Environment Variables button at the bottom. A new window opens with two lists: User variables at the top and System variables at the bottom.

Step 2: Create the JAVA_HOME variable

  1. In the System variables list, click New.
  2. In Variable name, type exactly this:

JAVA_HOME

  1. In Variable value, type the full path to your JDK folder. For example, if you installed Temurin JDK 17, the path is something like:

C:\Program Files\Eclipse Adoptium\jdk-17.0.x

If you installed Oracle JDK 17, it is something like:

C:\Program Files\Java\jdk-17

Do not add \bin at the end of this path. JAVA_HOME must point to the JDK folder itself, not to the bin folder inside it.

  1. Click OK to save the new variable.


Setting the JAVA_HOME environment variable in Windows 11 settings


Step 3: Check for an old JAVA_HOME first

If JAVA_HOME already exists in the list, do not create a second one. Click on the old JAVA_HOME, click Edit, and change its value to your new JDK path. Then click OK. Two JAVA_HOME variables cause confusion, and Windows uses only one of them.

Step 4: Close the windows

Click OK on the Environment Variables window, then OK on the System Properties window. Your JAVA_HOME setting is now saved, but open programs do not see it yet. Close any open Command Prompt or terminal windows, because they still use the old settings.

How to Add Java to the Path

The Path is a list of folders that Windows searches when you type a command. If the JDK bin folder is in the Path, you can type java from any folder and Windows will find it. If it is not in the Path, you get the error that java is not recognized as a command.

Step 1: Open the Path variable

  1. Open Environment Variables again, the same way as before.
  2. In the System variables list, find Path and click Edit. A list of folders opens.

Step 2: Add the Java bin folder

  1. Click New.
  2. Type exactly this:

%JAVA_HOME%\bin

This text means the bin folder inside the folder that JAVA_HOME points to. Using %JAVA_HOME% instead of a fixed path is better, because if you change JAVA_HOME later, the Path updates with it.

  1. Click OK on the Edit window, then OK on the Environment Variables window, then OK on the System Properties window.

Step 3: Test it in a new terminal

Open a brand new Command Prompt. Old terminal windows do not see the new settings, so you must open a new one. Type these two commands, one at a time:

java -version

javac -version

The first command checks the Java runtime. The second checks the Java compiler. Both should show the same version number, for example 17.0.x. If both commands work, Java is correctly on your Path. If java -version works but javac -version does not, you installed only a JRE, which is the runtime without the compiler. Uninstall it and install a full JDK instead.

How to Check That Java Is Installed Correctly

Do these three quick checks after any JDK setup. They take less than a minute, and they tell you exactly what is wrong if something is not working.

Check 1: java -version. Open a new Command Prompt and type java -version. You should see the version you installed. If the version is different from the one you installed, another JDK is active. Check your Path order and your JAVA_HOME value.

Check 2: echo %JAVA_HOME%. In the same Command Prompt, type echo %JAVA_HOME% and press Enter. Windows should print the path to your JDK folder. If it prints %JAVA_HOME% back to you, the variable is not set. Go back to the JAVA_HOME section and set it again.

Check 3: flutter doctor -v. If you have Flutter installed, type flutter doctor -v in a terminal. The long form shows the Java version that Flutter found. Look for the Android toolchain section. It should show a green checkmark and a Java version. If it shows a Java error, read the error message carefully, because it usually names the exact problem.

How to Point Flutter to Your JDK

Sometimes Flutter finds the wrong JDK, or it cannot find any JDK at all. You can point it to the exact JDK you want with one command. This is useful when you have two JDKs on your computer and Flutter keeps picking the wrong one.

Open a terminal and run this command, with your own JDK path in place of the example:

flutter config --jdk-dir="C:\Program Files\Java\jdk-17"

Replace the path inside the quotes with your real JDK folder. For Temurin, the path is usually under C:\Program Files\Eclipse Adoptium. After you run the command, run flutter doctor -v again and check that the Java version changed to the one you set.

To remove this setting later and let Flutter choose again, run the same command with an empty value:

flutter config --jdk-dir=""

You do not need this command if the bundled JDK already works. Only use it when flutter doctor shows a Java problem that the normal setup did not fix.

Common Problems and Fixes

Even a careful setup can hit an error. These are the most common Java and JDK problems in Flutter, with their fixes.

Problem 1: java is not recognized as an internal or external command

This means Windows cannot find Java. The JDK bin folder is not in the Path, or you are using an old terminal window. Open a new Command Prompt and try again. If it still fails, check that %JAVA_HOME%\bin is in the System Path, and check that JAVA_HOME points to a real JDK folder with a bin folder inside it.

Problem 2: flutter doctor says Java version is too old

This happens when Flutter finds an old JDK, often JDK 8 or JDK 11, before it finds your new one. Modern Android Gradle Plugin needs Java 17 or higher. Check which Java is active with java -version. If it shows an old version, fix your JAVA_HOME and Path, or use flutter config --jdk-dir to point Flutter to the new JDK. Also check that no old JDK folder is listed before the new one in the Path.

Problem 3: Gradle fails with an Unsupported class file major version error

This error means your Gradle version is too old for your Java version. For example, Gradle 7 cannot run on Java 21, and Gradle 8 cannot run on Java 25. The fix is to match the two versions: use Java 17 with Gradle 7.3 or higher, Java 21 with Gradle 8.5 or higher, and Java 25 with Gradle 9.1 or higher. The easiest fix for a beginner is to switch to JDK 17, which works with the widest range of Gradle versions.

Problem 4: Android Studio uses a different JDK than the terminal

Android Studio has its own Gradle JDK setting, which can differ from the JDK in your terminal. Open File, then Settings, then Build, Execution, Deployment, then Build Tools, then Gradle, and look at the Gradle JDK dropdown. Set it to the same JDK that your terminal uses, or set it to the bundled JDK that Android Studio ships with. Then restart Android Studio and try the build again.

Problem 5: JAVA_HOME is set but Flutter still cannot find Java

This usually means the JAVA_HOME value has a mistake. The most common mistakes are a missing folder, a path that points to the bin folder instead of the JDK folder, or a path with a typing error. Copy the path from File Explorer instead of typing it by hand. Open the JDK folder in File Explorer, click the address bar, copy the path, and paste it into the JAVA_HOME value. Then open a new terminal and test again.

Problem 6: The emulator fails after a JDK change

The emulator does not use your JDK directly, but a wrong Java setup can still break the build that runs on the emulator. If the emulator stops working after you change the JDK, run flutter doctor -v first and fix any Java error it shows. If the emulator itself has a problem, read the Techmithu guide How to Fix Android Studio Emulator Not Working, which covers the emulator fixes in detail.


Terminal window showing flutter doctor check with a green checkmark


Try It Yourself

Do this short checklist now, while the steps are fresh in your mind. Tick each item as you finish it.

  • Open a new Command Prompt and run java -version. Write down the version number you see.
  • Run javac -version in the same window. Check that both commands show the same version.
  • Run echo %JAVA_HOME% and check that it prints your JDK folder path.
  • Run flutter doctor -v and check that the Android toolchain section shows a green checkmark.
  • Open Android Studio, go to File, then Settings, then Build Tools, then Gradle, and note which JDK is selected.
  • Create a new Flutter project or open an existing one, and run flutter run or flutter build apk to test a real build.

If all six items pass, your Java JDK setup is complete. If one item fails, go back to the section that covers it and fix it before you move on.

Conclusion

Setting up the Java JDK for Flutter and Android Studio is a one time job, and it is simpler than it first looks. The JDK is needed because Gradle, the Android build tool, runs on Java. Most beginners can simply use the JDK that comes bundled with Android Studio, and that is the easiest path. If you need your own JDK, install JDK 17 from Temurin or Oracle, set JAVA_HOME to the JDK folder, add %JAVA_HOME%\bin to the Path, and check your work with java -version and flutter doctor.

Remember the version rules. Use JDK 17 for the safest Flutter setup, JDK 21 if your Gradle version is 8.5 or higher, and JDK 25 only with Gradle 9.1 or higher. Do not use JDK 27 for Flutter yet, and do not use JDK 8 or JDK 11, because they are too old for modern Android tools. Keep one JDK as your main choice, and point Flutter to it with flutter config --jdk-dir only when you need to.

Once Java is set up, your next step is to build your first app. Read How to Create Your First Flutter App to make a Hello World app in ten minutes, and read What is Flutter? if you want a simple explanation of what Flutter is and how it works. Your JDK is now ready, so your first build should work without a Java error.

FAQs

Do I need to install Java separately for Flutter?

No, not in most cases. Android Studio comes with its own JDK, and Flutter uses it by default. You only need to install a JDK yourself if Android Studio is not installed, if you want a specific version, or if a project needs a version that Android Studio does not bundle.

Which JDK version is best for Flutter in 2026?

JDK 17 is the safest choice for beginners, because it is the minimum version for modern Android Gradle Plugin and it works with the widest range of Gradle versions. JDK 21 also works well with Gradle 8.5 or higher. JDK 25, the latest long term support release, works with Gradle 9.1 or higher.

Is the JDK free to download?

Yes. Eclipse Temurin from Adoptium is free and open source, with no account and no payment. Oracle JDK 25 is free to use under the Oracle No-Fee Terms and Conditions until September 2028. Download Java only from adoptium.net or oracle.com, never from a random download site.

What is JAVA_HOME and why do I need it?

JAVA_HOME is an environment variable that stores the path to your JDK folder. Tools like Gradle and Flutter read it to find Java on your computer. Without it, they may fail to find Java even when it is installed. Set it to the JDK folder itself, for example C:\Program Files\Java\jdk-17, and never add \bin to the end of it.

How do I check which Java version Flutter is using?

Run flutter doctor -v in a terminal. The Android toolchain section shows the Java version that Flutter found. You can also run java -version in a Command Prompt to see the Java version that your terminal uses.

Can I use JDK 25 or JDK 27 for Flutter?

You can use JDK 25 only if your Gradle version is 9.1 or higher, because older Gradle versions cannot run on Java 25. Do not use JDK 27 for Flutter yet, because most Flutter projects and plugins are not tested with it, and it is not a long term support release.

What is the difference between a JDK and a JRE?

A JDK is a Java Development Kit. It contains the compiler and the tools needed to build Java programs. A JRE is a Java Runtime Environment. It contains only the runtime needed to run Java programs, without the compiler. Flutter needs a full JDK, not only a JRE, because the build tools need the compiler.

Why does flutter doctor show a Java error when Java is installed?

The most common reason is that JAVA_HOME is wrong or the Path is missing the JDK bin folder. Another common reason is that Flutter found an old JDK first. Check java -version, check echo %JAVA_HOME%, and use flutter config --jdk-dir to point Flutter to the correct JDK folder.

Do I need to learn Java to use Flutter?

No. Flutter apps are written in Dart, not Java. You only need Java installed so that the Android build tools can run. You will not write Java code to build a normal Flutter app.

Should I delete the old JDK after installing a new one?

You can keep an old JDK if another program needs it, but do not let it confuse your setup. Make sure JAVA_HOME and the Path point to the JDK you want Flutter to use, and use flutter config --jdk-dir if Flutter keeps finding the old one. If no program needs the old JDK, you can uninstall it from Settings, then Apps, then Installed apps.

Related Articles on Techmithu

If this guide helped you set up Java for Flutter, read How to Install Flutter and Android Studio on Windows 11 next to complete your full Flutter setup, and share this guide with a friend who is starting Flutter.

 

Comments

Popular posts from this blog

How to Install Flutter and Android Studio on Windows 11 - Complete Guide for Beginners

How to Make Your Laptop Battery Last Longer

Laptop Course for Beginners - Complete Guide in Simple Words