If you are getting error "No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?" while compiling any java application either using Eclipse, NetBeans and any other IDE, the simple meaning of this error is; you are trying to compile your Java program using JRE which is not possible. To compile any Java program we need JDK.
There could be two reasons which causing this error. Will see both the ways to fix this issue.
How to check installed version of Java in your machine.
1. If you don't have JDK installed in your machine/Computer.
- To resolve this you need to download the latest version of JDK and install it in your machine.
- Then setup environment variable and path. for more check here.
2. If JDK is already installed in your machine but installed JRE path is not setup to JDK path.
- Open eclipse
- Go to Window > Preferences > Java > Installed JREs > and check your installed JREs.
- There should be a entry available for JDK in installed JRE. In case there is no JDK entry then you have to add path of installed JDK from your machine.
To do this:
- Go to C drive of your computer and find the directory of JDK in program files. e. g. C:\Program Files\Java\jdk1.8.0_111
- Copy this path and add this path in your installed JREs option in your IDE.
Inatalled JRE in eclipse |
- Click on Add button from right side of window. A new window will appear, click on standard VM > Next > In JRE home section put the path of installed JDK from program files and click on finish.
JRE defination window |
- After doing these all JDK will be appear in your installed JREs window. From there you mark/check JDK and apply.
Inatalled JRE in eclipse |