I have recently downloaded Maven and followed the instructions given on this this page. I already have ant installed on my machine.
Now, if I want to verify that Maven is installed perfectly or not it is giving me error that JAVA_HOME is not set correctly, but same works perfectly fine for ANT.
For Maven I tried :
1. open cmd
2. type mvn -version
3. Error appeared :
C:\Users\Admin>mvn -version
ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jre7\bin"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
For ANT I tried and worked :
1. open cmd
2. type mvn -version
3. Apache Ant(TM) version 1.9.1 compiled on May 15 2013
I went to the directory to check that java.exe is actually there in that directory or not and it was there. I checked the environment variables they set fine. I restarted the system and checked again but same problem. Please let me know what am I missing.
JAVA_HOME should point to jdk directory and not to jre directory. Also JAVA_HOME should point to the home jdk directory and not to jdk/bin directory.
Assuming that you have JDK installed in your program files directory then you need to set the JAVA_HOME like this:
JAVA_HOME="C:\Program Files\Java\jdkxxx"
xxx is the jdk version
Follow this link to learn more about setting JAVA_HOME:
http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html
Do not include bin in your JAVA_HOME env variable
Follow the instruction in here.
JAVA_HOMEshould be like this
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07
JAVA_HOME = C:\Program Files\Java\jdk(JDK version number)
Example: C:\Program Files\Java\jdk-10
And then restart you command prompt it works.
Just remember to add quotes into the path if you have a space in your path to java home.
C:\Program Files\java\javaxxx\ doesn't work
but
"C:\Program Files\java\javaxxx\" does.
The JAVA_HOME should point to the JDK home rather than the JRE home if you are going to be compiling stuff, likewise - I would try and install the JDK in a directory that doesn't include a space. Even if this is not your problem now, it can cause problems in the future!
You are pointing your JAVA_HOME to the JRE which is the Java Runtime Environment. The runtime environment doesn't have a java compiler in its bin folder.
You should download the JDK which is the Java Development Kit. Once you've installed that, you can see in your bin folder that there's a file called javac.exe. That's your compiler.
JAVA_HOME should point to jdk directory like in the image with new variable, like below
PATH should point to jdk bin like below
Run the below command in your terminal and restart it.
> set JAVA_HOME="C:\Program Files\Java\jdk-xx.xx"
xx.xx is the java version
Related
I have tried every which way to declare JAVA_HOME in my system variables, but I keep getting the following error when running 'ionic Cordova build --release android'
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Your JAVA_HOME is invalid: C:\Program Files (x86)\Java\jdk1.8.0_301
I've tried appending it with "bin", I've tried wrapping C: Program Files (x86) in double quotes, I've tried uninstalling and reinstalling java, and I always get the same error. When I run echo %JAVA_HOME% it gives me:
C:\Program Files (x86)\Java\jdk1.8.0_301
How can I figure out what's wrong?
I can see a couple of problems here. The following instructions should help you resolve the issue:
The installation path has x86 which suggests that you have installed a 32-bit version of JDK. If your OS is 64 bit (which is mostly the case), download and install the 64 bit JDK.
While installing, the installer gives you an opportunity to change the installation location. The default suggested location has space that may be problematic and therefore I recommend you change it to something like C:\jdk.
Append the path of JDK bin folder to the PATH environment variable e.g. if the path of bin folder is C:\jdk\jdk1.8.0_301\bin, append this to the PATH environment variable and also move it to the top position.
Create a new environment variable, JAVA_HOME and put C:\jdk\jdk1.8.0_301 (i.e. the path, one level above the bin folder) as the value into it.
Finally, start a new cmd window and test the command, java -version.
I am trying to set up maven for my project and I am getting this error
"JAVA_HOME should point to a JDK not a JRE"
I know there are already similar question but it did not work. How can I point JAVA_HOME to JDK in windows. I am using IntelliJ IDEA
Control Panel -> System and Security -> System -> Advanced system settings -> Advanced -> Environment Variables -> New System Variable
I am going through the same process on Mac OSX. I installed the latest JDK, then installed Maven. Someone suggested I set the JAVA_HOME variable so I pointed it to the JDK installation folder. When running Maven mvn compile exec:java I received the same error NB: JAVA_HOME should point to a JDK not a JRE.
All I did was unset the JAVA_HOME variable and it worked.
do it thru cmd -
echo %JAVA_HOME%
set set JAVA_HOME=C:\Program Files\Java\jdk1.8.0
echo %JAVA_HOME%
I met the same problem. (Window 10 environment)
I solved it by deleting the JAVA_HOME="C:\Program Files\Java\jdk1.8.0_161\bin" in the User Variables instead of adding to the System Variables directly.
Then I test that editing JAVA_HOME="C:\Program Files\Java\jdk1.8.0_161\" worked too.
When I run "mvn -version" in command prompt window, it shows "Java home: C:\Program Files\Java\jdk1.8.0_161\jre".
In conclusion, I guess the JAVA_HOME shouldn't include bin directory.
I added JAVA_HOME path in user variable and omit the "/bin".
I tried every method given here but only this worked for me.
I have spent 3 hours for solving the error The JAVA_HOME environment variable is not defined correctly. This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
Finally I got the solution. Please set the JAVA_HOME value by Browse Directory button/option. Try to find the jdk path. Ex: C:\Program Files\Java\jdk1.8.0_181
It will remove the semicolon issue. :D
My JAVA_HOME was set correctly but I solved this issue by running Command Prompt as Administrator
In Mac OS the hierarchy library > java > JavaVirtualMachines - (inside this folder there are different versions of jdk) select your desired version and inside jdk-version folder there is a contents folder inside contents you'll find "Home" folder
while declaring $JAVA_HOME you haVE TO GIVE THAT HOME PATH for example-
(normal shell commands)
open terminal type vi .bash_profile
(to open file name bash_profile)
press "i" to enable insert mode
give java home path as-
export JAVA_HOME=/Library/java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
After editing press esc to exit editing mode
then :wq to quit and save
This will remove JAVA_HOME should point to a JDK not a JRE error
and also saves you from future errors
For mac OS, this worked for me... none of the above solutions
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
$ source .bash_profile
Be sure to use the correct path!
I mistakenly had written C:\Program Files\Java\. Changing it to C:\Program Files\Java\jdk\11.0.6\ fixed the issue.
In cmd I then checked for the version of maven with mvn -version.
Just as an addition to other answers
For macOS users, you may have a ~/.mavenrc file, and that is where mvn command looks for definition of JAVA_HOME first. So check there first and make sure the directory JAVA_HOME points to is correct in that file.
if You have
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Error
so do one thing ...type
C:>dir/x
and you will see the PROGRA~1 or May ~2
and After int Environment Variable Chang The JAVA_HOME Dir Like This
JAVA_HOME:- C:\PROGRA~1\Java\jdk1.8.0_144\
also Set In Path :-%JAVA_HOME%\bin;
And it Works
Make sure that you do NOT have a JRE path, if you have delete it.
Add JAVA_HOME in the System variable. Variable value: C:\Program Files\Java\jdk-10.0.2 (location of JDK without bin)
Add M2 in the System variable. Variable value: C:\dev\maven\apache-maven-3.5.4\bin (location of maven with bin)
Add M2_HOME in the System variable. Variable value: C:\dev\maven\apache-maven-3.5.4 (location of maven without bin)
Add %JAVA_HOME% and %M2% in Path System Variable or C:\Program Files\Java\jdk-10.0.2 and C:\dev\maven\apache-maven-3.5.4\bin --> For windows 10, just add the location. For other version, at the end of the Variable Value field add semicolon then the location Ex: ;%JAVA_HOME%;%M2%
I did not check if the addition or removal of bin changes the result but nonetheless this works for me.
In addition to sovas' response on how to add the JAVA_HOME variable, if it was working before and stopped working, ensure that the path still exists. I updated Java recently which deleted the old version, invalidating my JAVA_HOME environment variable.
This worked for me for Windows 10, Java 8_144.
If the path contains spaces, use the shortened path name. For example, C:\Progra~1\Java\jdk1.8.0_65
Under System Variables add below
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_201
JDK_HOME = %JAVA_HOME%\bin
M2_HOME = C:\apache-maven-3.6.0
MAVEN_BIN = %M2_HOME%\bin
MAVEN_HOME = %M2_HOME%
Under path Add these
%M2_HOME%
%JDK_HOME%
you should only add this path to Manage Jenkins -> Global Tool Configuration -> JDK
for java 11
/usr/lib/jvm/java-11-openjdk-amd64
for java 8
/usr/lib/jvm/java-8-openjdk-amd64
And then use same in your jenkins jobs accordingly
In IntelliJ IDEA go to File>Project Structure>SDK>JDK home path.
Copy it and then go to
My Computer>Advanced Settings>Environment Variables
Change the JAVA_HOME path to what you have copied.
Then open new cmd, and try mvn -v
It worked for me !!!
Add JAVA_HOME = C:\Program Files\Java\jdk(version) in User variable, it works for me. For me, it doesn't work with bin and even if I create JAVA_HOME in system variable
just remove the semicolon at the end of JAVA_HOME variable's value.
set JAVA_HOME as C:\Program Files\Java\jdk1.8.0_171
It worked for me.
I had this issue but for Mac Os, I set the JAVA_HOME variable in the .bash_profile to be export JAVA_HOME=$(/usr/libexec/java_home) then save. After that ran source ~/.bash_profile finally mvn -version and it fixed the issue. Hope that helps
First, ensure that the Maven bin is in your Environmental Variable PATH entry.
If it is, make sure your entries aren't somehow out of order, and that JAVA_HOME is before Path in the list, or any entry that references %JAVA_HOME%. I was getting the same error when I was trying to check my maven version.
I have a few extra path variables that reference %JAVA_HOME%, or a different version of a JDK and Maven was mixed in between. I moved my Maven path entry below my %JAVA_HOME% one and now everything is working when I use Maven from cmd.
But it is Windows, so perhaps my just opening and closing the Environment Variables setting somehow made everything better.
Windows 10 Home for me:
I'm studying maven through a udemy course. First time environment variables were ok. I had on JAVA_HOME on SYSTEM VARIABLE like this:
D:\Install\Java\jdk-12.0.1;D:\Install\apache-maven-3.5.4-bin\apache-maven-3.5.4
After some days, don't know what's happened, I began to receive:
C:\Users\Franco>mvn -version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
After trying all above, I tried to delete jdk the entry on SYSTEM VARIABLES, and putting it on USER VARIABLES, so now I have:
JAVA_HOME on USER VARIABLES: D:\Install\Java\jdk-12.0.1
JAVA_HOME on SYSTEM VARIABLES: D:\Install\apache-maven-3.5.4-bin\apache-maven-3.5.4
now restarting CMD I have:
C:\Users\Franco>mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)
Maven home: D:\Install\apache-maven-3.5.4-bin\apache-maven-3.5.4\bin\..
Java version: 12.0.1, vendor: Oracle Corporation, runtime: D:\Install\Java\jdk-12.0.1
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
In my case the error started showing up as Java version got updated. So JAVA_HOME path became invalid.
Please check
Location referred to in JAVA_HOME exists.
If it's like my case, update the value from the old path to the new path.
(A better fix would be to set java update such that it auto upgrades the JAVA_HOME reference.)
Even after trying this solution from sovas which is accepted if it does not work
RESTART intellij / CMD prompt instead of trying on the existing opened
i was trying the command from terminal under intellij but still getting same problem.
Do reopen cmd / INTELLIJ and the variable will get reloaded. It fixed the problem for me (ofcourse after correcting the Path to JDK not jre and removing the bin
I'm running Ubuntu 15.10.
So, I just uploaded the Android Studio from the site.
After that I unpacked the zip file.
Went to android-studio/bin and found studio.sh.
Sit permission to be executed chmod +x studio.sh.
Ran the file to install with this line: ./studio.sh.
Then I had the error
No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.
I have already netbeans installed. I just ran the instalation package file JDK + Netbeans, so it was supposed to have java environments variables sit.
If I run pintenv the PATH environment variable do not hold the path to java. This is what I have:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
So, how can I find the location where Java was installed? I could set the PATH variable manually.
Any idea how to solve this issue?
I had very simmilar problem, I had all JAVA_HOME and other things done but I forget to set below lines in terminal:
update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_45/bin/java 100
update-alternatives --config java
I am building a project in Java.
I have this error:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
I have installed a JDK and the folder: C:\Program Files\Java\jre6\lib is in my system but the file tools.jar is not there.
Yes, you've downloaded and installed the Java Runtime Environment (JRE) instead of the Java Development Kit (JDK). The latter has the tools.jar, java.exe, javac.exe, etc.
In case this is still an issue for anyone, I have a bit of clarification on the previous answers. I was running into this same issue using ant with only a JDK installed. Although, the JDK installer gave me a directory structure like this:
Directory of C:\Program Files\Java
05/08/2012 09:43 AM <DIR> .
05/08/2012 09:43 AM <DIR> ..
05/08/2012 09:46 AM <DIR> jdk1.7.0_04
05/08/2012 09:19 AM <DIR> jre6
05/08/2012 09:44 AM <DIR> jre7
0 File(s) 0 bytes
and when I ran ant, it complained about not finding tools.jar under the jre7 subdirectory. It wasn't until I set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_04" that the error went away.
Install the Java SDK.
Add a System Environment Variable called JAVA_HOME with the value of JDK location.
Go to Control Panel\System and Security\System. Advanced System Settings, Environment Variables, System Variables, New... Example:
Variable Name:JAVA_HOME
Variable Value: C:\Program Files\Java\jdk1.7.0_21
Close/reopen your CMD window so that the new variable takes effect before attempting to re-run the ant command.
I had the same problem and copying C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar to C:\Program Files\Java\jre6\lib\ext worked for me
If you have installed JDK 9.0.1 you will also have this problem as the tools.jar has been deprecated. See migration document.
Set your JAVA_HOME environmental variable to point to C:\Program Files\Java\jdk1.7.0_02.
If you are in Linux you can solve this by installing java on the system:
sudo apt-get install openjdk-7-jdk openjdk-7-jre
No, according to your directory structure, you have installed a JRE, not a JDK. There's a difference.
C:\Program Files\Java\jre6\lib
^^^^
It should be something like:
C:\Program Files\Java\jdk1.6.0_24
Don't spend too much time looking for tools.jar. If you get an error like that, don't be upset.
If you already have java JDK 1.5, go to your lib folder, and the tools.jar should be available there. Copy and paste it in your ant bin folder, then try to use the command ant -version.
You should see the expected result.
I had the same issue on a linux machine. I was quite frustrated at first, because I have installed both the JDK and JRE. I am using version 1.6, 1.7 and 1.8 simultaneously, and I have played a lot with the alternatives to have everything set properly.
The problem was quite stupid to solve, yet counter-intuitive. While I was using the correct JDK, I paid attention to the path of the tools jar maven complained about - it was expecting it to be
$JAVA_HOME\..\lib\tools.jar
The $JAVA_HOME variable pointed directly to my jdk folder (/usr/local/java which was also the correct $PATH entry and alternative sym link). It actually searches for the lib folder outside the java directory, because:
$JAVA_HOME\..\lib\tools.jar
will resolve to
/usr/local/lib/tools.jar
and that is not a valid location.
To solve this, the $JAVA_HOME variable should instead point to this location /usr/local/java/jre (assuming the JDK path is /usr/local/java) -- there is actually jre folder inside the JDK installation directory, that comes with each JDK. This new setup will cause maven to look at the JRE directory, that is part of the JDK:
$JAVA_HOME\..\lib\tools
which now resolves to
/usr/local/java/jre/../lib/tools.jar
and finally to
/usr/local/java/lib/tools.jar
which is where the tools.jar really resides.
So, even if you are indeed using the JDK instead of the JRE, the $JAVA_HOME has to point to the JRE. Remember, the OS alternative should still refer to the JDK.
go to your jdk path where you installed your java
For e.g In my PC JDK installed in the following path
"C:\Program Files\Java\jdk1.7.0_17\";
After go to the lib folder e.g "C:\Program Files\Java\jdk1.7.0_17\lib"
in the lib directory there is tool.jar file
Copy this file and past it in the lib forlder of jre7 directory
for e.g
"C:\Program Files\Java\jre7\lib"
You may face similar problem on Ubuntu:
Embedded error: tools.jar not found: /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
The problem is with JAVA_HOME that is not set properly.
So, on Ubuntu 14.04 x64 using Java8:
sudo apt-get install openjdk-8-jdk openjdk-8-jre
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
As many people mentioned, it looks like you are looking in your JRE instead of the JDK for the tools.jar file.
I would also like to mention that on recent versions of the JDK, there is no more tools.jar file. I downloaded the most recent JDK as of today (JDK version 12) and I could not find any tools.jar. I had to download JDK version 8 (1.8.0) here https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to get the tools.jar file. I downloaded that version, took the tools.jar file and put it into my recent version's lib folder.
It's worth observing that tools.jar has been removed from the JDK since Java 9. https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-055EA9F4-835E-463F-B9E1-9081B3D9E55D
If people are facing this issue compiling a Java program with JDK 9+, you may need to review the dependencies of your projects.
In my case, I was trying to compile a project using AspectJ and the Maven plugin org.codehaus.mojo:aspectj-maven-plugin:1.11. After searching online, I found an alternative that supports Java 9+: dev.aspectj:aspectj-maven-plugin:1.13.M3.
I had the same problem even after installing Java JDK and set JAVA_HOME to ..\jdk1.6.0_45\bin folder.
Ant is still trying to find tools.jar in C:\Program Files\Java\jre6\lib folder.
I've fixed it by adding JAVACMD environment variable and set path for it to java.exe in the jdk folder.
In my case it was C:\Program Files\Java\jdk1.6.0_45\bin\java.exe
it has been solved with me in windows os by setting the JAVA_HOME variable before running as follows:
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111
Make sure that both the %JAVA_HOME% and %JAVA_HOME%/bin paths are added to your PATH variable.
All the answers about copying tools.jar into the correct position is a poor idea at best.
Make sure that your IDE can find these jars the way it was designed and intended for.
In eclipse window> preferences>Java> Installed JRE, I pointed the directory to the jre directory in the jdk 1.7 and i worked file for me
e.g C:\Program Files\Java\jdk1.7.0_71\jre
I had my JDK_path (C:\Program Files\Java\jdk1.7.0_79) in my JAVA_HOME and also the JDK_path\bin in my PATH. But, still my ant was using the JRE instead of JDK.
The issue was I had C:\ProgramData\Oracle\Java\javapathbefore my JDK_path in PATH variable. I simply moved my JDK_path before the oracle one and the issue solved.
solving this problem I have simply copied the tools.jar file from C:\Program Files\Java\jre1.8.0_112\lib to C:\Program Files\Java\jdk1.8.0_112\lib so that I have two tools.jar files instead of one and problem disappeared.
Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
if you have installed jdk then
..Java/jdkx.x.x
folder must exist there so in stall it and give full path like
C:\Program Files\Java\jdk1.6.0\lib\tools.jar
Make sure that your classpath is set correctly and pointing to the correct version of the JDK that you have installed. Also, are you using Open JDK? I have had this issue before after I tried to move from open JDK to Suns JDK. This is an example of how that issue could be fixed.
maven-compiler-plugin use jdk ,not jre,
tools.jar is in C:\Program Files\Java\jdk1.6.0\lib\tools.jar
you must config project JRE System Libary with jdk,not jar. This is the simplest solution.
Right click on your ant file
Go to "Run as" then click on "Ant Build..."
Go to the "JRE" tab
Select a JDK and not a JRE
For me what's working: I downloaded an old version of Java 1.7
I actually set my JAVA_HOME from C:/program files X86/Java BUT after I installed the 1.7 version I had another Java in program files/Java. And at this moment I found the tools.jar here. Then I changed for this new path and it's working
I was also facing the same error.
This was removed after setting Java_Home path to C:\Program Files\Java\jdk1.8.0_121.
Please ensure bin is not included in the path and no slash is there after jdk1.8.0_121 after you have defined %JAVA_HOME%\bin in the system path variable.
If you're in a RHEL environment the package name containing tools.jar would end with "openjdk-devel".
This is the solution for Windows: in Computer > Advanced system settings > Advanced > Environment variables..., add this in System variables:
I have downloaded tools.jar and after that I copied it into path in error message.
C:\Program Files\Java\jdk-11.0.1\bin > paste here tools.jar
After that I have restarted Spring Tool Suit 4 and everything was working.
When I was trying to fix that problem I have made new environmental variable:
Control Panel / System / Advenced / Environmental variables / new
Name : JAVA_HOME
Value: C:\Program Files\Java\jdk-11.0.1
But I do not know is it necessary.
maybe you have updated the JREs in the OS, and the addition has added in the "path" of the environment variables an entry ".../Oracle/jer" that overwrites your JAVA_HOME.
try to remove it from the "path" by leaving JAVA_HOME.
I have researched this and none of the solutions that I have seen have fixed my error.
What is happening is I tried to install Java EE version got the above error and then found out that I must install Java SE first. So I installed Java SE and set the JAVA_HOME variable to C:\Program Files\Java\jdk1.8.0 which is where I installed my JDK. I also put C:\Program Files\Java\jdk1.8.0\bin in my PATH variable. Still not working. I also tried the JAVA_HOME variable with C:\Program Files\Java\jdk1.8.0\bin and that didn't work. I also tried installing without the PATH variable being updated to where I put my JDK.
I'm really getting confused as to why this is happening. I've had Java before and I don't recall having this much trouble installing it.
PS I don't install from the command line I just click the download icon in Firefox and then click the download.
Try running the installer at your commandline and pass the path of the JRE instead of the JDK.
For Example:
java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre8"
I had the exact same problem and even downloading the version without JDK didn't help!
I simply installed it from the terminal with passing the JRE For Example:
java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre7"
and it worked like a charm!
I had the same problem but an additional step was required in order to install using the command line. In the command window (on my Windows 10 laptop) I had to use:
cmd /d
to tell the cmd window to ignore registry AutoRun commands before the java installation executable would run. After using cmd /d, and changing to the directory where the .exe file was at, the following worked:
java_ee_sdk-6u4-jdk7-windows-x64.exe -j "%JAVA_HOME%"
Where JAVA_HOME is a system environment variable pointing to an existing JDK installation (C:\Program Files\Java\jdk1.8.0_65).
Uninstall everything, all of it.
Then go to your Program Files folder (and (x86) folder if on a 64bit Windows) and physically remove any Java folders.
Reinstall Java SE and then the EE packages. Sometimes Windows appears to get a bit confused and you need to help it figure out what to do.
If you want to uninstall, go to the glassfish folder and open the command prompt, then type:
uninstall.exe -j <The path to your JRE>
These points may be helpful.
java EE SDK7 contains glassfish v4.0 and it compatible with JDK6 and JDK7.
java EE SDK8 contains glassfish v5.0, it compatible with only JDK7 and JDK8, not JDK 9 or beyond.
So environment variable JAVA_HOME has to point to the root directory of one of the mentioned JDK. and %JAVA_HOME%\bin should be added to environment variable path
Despite having followed all of the above, setup of java EE SDK7 gets error:
could not find the required version of the Java(TM;
as Bakudan and laf8 said,
open cmd using run, with /d /a options as followed.
cmd /d /a
and next run SDK7-setup with -j option like this command
sdk7.exe -j "%JAVA_HOME%"
note that %JAVA_HOME% enclosed BY ""
This was happening to me when I tried to run the Java EE installer. What I did, was to download from Oracle a Java EE version which didn't include the JDK, because it was already installed in my system. Problem solved!
Open regedit.
goto :HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\
set CurrentVersion to desired JDK version.
Check JavaHome and RuntimeLib path's for selected jdk version folder
Check JavaHome and RuntimeLib path's for selected jdk version folder
example: "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.7".
example:
JavaHome=C:\Program Files (x86)\Java\jdk1.7.0_79
RuntimeLib=C:\Program Files (x86)\Java\jdk1.7.0_79\jre\bin\server\jvm.dll
Source: http://tech-read.com/2009/05/19/how-to-solve-error-could-not-find-java-runtime-2-environment-while-opening-an-ide/