Java Runtime Environment, or JRE is a piece of software that provides the necessary functions and system resources for a typical Java program to run. It is widely used in developing and distributing Java programs.
When you try to run a software written in Java without setting up the JRE correctly before that, the error "Java Runtime Environment not found" error would pop up. The error message basically means that you have not installed JRE on your computer, or in case you did, the system can't find it. It's also possible that the application which is being installed is not compatible with the Windows operating system or the application has a problem.
In this article, we will show you how to fix the "Java Runtime Environment not found" error on Windows and Ubuntu.
Add JAVA_HOME environment variable
Java Runtime Environment relies on an environment variable named JAVA_HOME in otder to locate where to find resources for programs written in Java. In many cases, a corrupt JRE setup or Windows misconfiguration may cause the JAVA_HOME variable to be deleted, hence the system cannot find JRE when needed.
Before proceeding, please verify whether you actually have Java installed or not by opening C:\Program Files\Java and look for a folder called jre6, jre7 or jreX with X being a version number. If it's there and the folder has files inside it, then JRE is installed. Remember the installation path of JRE as we will need it later.
In order to add JAVA_HOME back to the list of environment variables, follow the instructions below.
First, on the Desktop, right-click in My Computer (This PC) icon, then select Properties > Advanced system settings on the left side.
In the new System Properties, select Advanced tab, then click on Environment Variables button to open up the list of all environment variables.
In the Environment Variables pop-up, select New.. in System Variables section to create a new system-wide environment variable. Input JAVA_HOME in the Variable name box and C:\Program Files\Java\jre7\bin to Variable value box. Remember to replace the value in Variable value box with the one in your specific computer, otherwise it won't work correctly.
Try reinstalling Java Environment Variable
There are numerous people who has faced the same problem, and a smart guy named appleoddity from WhatTheTech came up with an automated script that fixes these kind of problem once and for all. Follow the instruction below if the solution above does not work for you.
- Completely uninstall every single Java installation from your computer. By Java, I mean both the JRE and JDK. You can use the built-in Programs and Features on Windows or any third party utility (no need for a paid program though).
- Download fixjava.bat from this page and run it. If you are using Windows Vista or Windows 7, 8, 10, you must right-click on the file and select Run As Administrator.
- Once the installation has done, download a fresh Java Runtime Environment installer to your computer and reinstall it. Notice that you have to select the correct 32-bit or 64-bit version that matches your system architecture.
Install Java on Ubuntu
Installing Java in Linux should be easy using package managers, such as apt, yum, or pacman, depending on your Linux distribution. However, there are times that you may encounter "java: command not found" error, even though you think you have installed it. We have covered this problem before, if you're encountering it, check out our guide on How to fix “java command not found”.
We hope that the information above is useful to you and helped you fix Java Runtime Environment not found error. We usually don't write about Java programming, but we have covered how to convert JSONObject to String that may be helpful to Java beginners.
If you have any questions, then please feel free to ask in the comments below.