I previously had Java 7 installed on my Windows PC. System environment variable also had location to it. I installed Java 10 without uninstalling 7 or changing the environment variable. Now when I go to CMD or Cygwin and enter Java -version it says Java 10.
I would think since I didn't change the environment variable that it would still be 7. How is Windows deciding what JDK to use?
Thanks!
Probably your JAVA_HOME or just PATH environment variables were changed.
Go to command line and do the following to check it:
> echo %JAVA_HOME%
For example, for me it gives back:
C:\Program Files\Java\jdk-9.0.4
How is Windows deciding what JDK to use?
Windows is NOT making decisions on its own. If you get version 10 information when you run java -version, it is because Windows is finding the folder containing java.exe corresponding to the version 10 first in the paths pointed to by the PATH environment variable. If you have installed Java using an installer, the installer would update the PATH variable for you. Check your PATH variable and you will see the Java 10 folder appearing there first and then Java 7 folder.
If you are using a java ide , you might find the location in JRE configurations. for example in eclipse :
windows > preferences > Installed JREs
.
Your JAVA_HOME variable might still be set to JDK 7 directory, however the Java 10 installation may have inserted it's /bin directory to the PATH.
Check to ensure that java 10 isn't on the PATH before java 7, or hasn't overwritten it.
CMD etc. check the path for the binaries for commands like java-version.
Related
I have multiple versions of Java installed on Windows 7 Home Premium 64-bit system. In order to install
Eclipse Java 2018-12
I have had to install the Java 11 JDK from the Oracle website. Despite setting JAVA_HOME and updating PATH in environment variables the only way to install and also run this version of Eclipse was to open a command prompt and
C:>set path=c:\program files\java\jdk11.0.1\bin
and then run Eclipse installer or installed instance.
The problem persists if I reboot my computer.
I want to be able to start eclipse by simply clicking on the desktop icon link.
The error I get when I try to run eclipse from the desktop link is:
Version 1.7.0_79 of the JVM is not suitable for this product. Version 1.8 out greater is required.
My C:\Program Files\Java\
contains folders
jdk1.0.7_79
jdk-11.0.1
jre7
I think I need all of these because I have some programs which I think retire java 7 so I don't think uninstalling java 7 is an option and don't think java 11 would replace it, or should I just get rid of java 7, is that what's causing the problem despite environment variables set correctly?
How can I fix this problem?
Thanks.
Add c:\program files\java\jdk11.0.1\bin to your Windows Environment PATH
The system was running C:\Windows\System32\javaw.exe
I fixed it by adding the Java 11 bin directory at the beginning of the Path environment variable instead of at the end of the string, separated by a semicolon.
First set JAVA_HOME then update path in environmental, refer screenshots attached.
Due to lack of space I uninstalled Java from my C: Drive and instead installed in D: drive. While doing this, I re-configured the JAVA_HOME, Path environment variables. However, when I do echo %JAVA_HOME% it displays the old path i.e. C:\Program Files\Java\jdk1.8.0_73
whereas the new path is D:\Program Files\Java\jdk1.8.0_92
Further, java -version and javac -version display the correct version of java which is 8.92 (older one was 8.73)
Pls suggest how to change configure java correctly. I am using Windows Server 2008 R2
Ok, I guess I figured out why this was happening :)
From the previous java installation (8.73), the JAVA_HOME was set in Env Variables > User Vraiables for Administrator
and I had created under System Variables.
Not sure which is the correct place, but I removed it from user variables now and it is all set. (Appreciate if someone could suggest the right place)
Thank you all for your inputs
I have multiple versions of Java installed in the environment(I know it is bad). I've set the JAVA_HOME to jdk 1_4 directory. This is not installed, but extracted from zip and placed it somewhere. We have java 1.8 JRE also installed in the system. I never set the path to this installed directory. Now i'm trying to run some ant script that depends on jdk 1_4. I get some exception saying that it is not able to find tools.jar in java1.8... .
My question is that when the path and java_home are set to jdk 14 why does the ant look for 1.8 version of java? I'm confused.
Update: I have looked up the duplicate issue.
Additional details: Java -version prints 1.8 with jdk 14 in the path and java_home. I uninstalled 1.8. reopened cmd tried java -version, now it errors out saying that it is not able to find java1.8 instead of trying to find the next java available in the path or java_home.
Error shown:
C:\Users\usrpao>java
Error: could not open `C:\Program Files\Java\jre8\lib\amd64\jvm.cfg'
I have multiple versions of Java installed in the environment(I know it is bad). I've set the JAVA_HOME to jdk 1_4 directory.
Not wrong at all. I have a similar setup because I have to switch between Java version.
First, install Java JDKs in the root of your drive. No spaces in the directory names. For example, C:\Java\Java-1.6-21 and C:\Java\Java-1.7-5.
In your Environment Variables section in your System Control Panel (under Advance), create an environment variable to point to each one of these Java Home directories. For example, JAVA_HOME_17 = C:\Java\Java-1.7.5 and JAVA_HOME_16 = C:\Java\Java-1.6-21. This should be a System Environment variable.
Create a JAVA_HOME environment variable that points to the Java version you want: JAVA_HOME = %JAVA_HOME_17%.
Now in the System PATH, prefix the PATH (the very first entry) with %JAVA_HOME%\bin.
When you open a console window, your default java and javac commands will be the correct Java version.
If you need to change a version, change the JAVA_HOME environment variable to point to the correct environment variable and open a new console window. Now that new Java will be in your path.
NOTE: It is vitally important that %JAVA_HOME%\bin is in the first part of your PATH before C:\Windows\System32. You don't want the java.exe that exists in that directory to be your default java.
You haven't specified the operating system, so:
on windows, java installs a java.exe in C:\Windows\system32, which is probably on the path before java_home, and so gets picked up
on Linux, various distributions that support multiple installed java versions will also have some symlink earlier on the path. Run 'which java' to determine where that symlink is
Multiple java versions in the system is the problem, I uninstalled all the java versions first. Restarted my machine. Path and java home points to the jdk 1.4. java -version now points to the version specified in the path. Thanks all.
So I just downloaded Android Studio, and am trying to set the JAVA_HOME variable so I can run it. I'm using windows 8 and have followed all the instructions I've been able to find to no avail... went to advanced system settings > environment variables and then set the JAVA_HOME variable with the value containing my path to jre7. I've double checked the path a million times, I don't see anything wrong with it(C:\Program Files (x86)\Java\jre7). I know the variable name is right, and I know that windows is excepting the variable, I've even restarted twice. What am I doing wrong here? The only thing I can think of that may be wrong is the fact that I'm pointing to a jre instead of a jdk, but I've always thought that both worked... anyway, the exact error message I get when I try to open Android Studio says:
No JVM installation found. Please install a 64-bit JDK. If you already
have a JDK installed, define a JAVA_HOME variable in Computer > System
Properties > System Settings > Environment Variables.
If a jre doesn't work in place of a jdk, then how do I go about getting one? I know nothing about Java I just want to get into this IDE and play around with Android.
No JVM installation found. Please install a 64-bit JDK.
It's asking for a 64-bit JDK. You say your environment variable is pointing at the following directory:
C:\Program Files (x86)\Java\jre7
There's two things wrong here. First, you're pointing to a JRE - Java Runtime Environment. This is not a JDK - Java Development Kit. The JRE is for running Java applications; the JDK is for developing Java applications. There's a significant difference there.
Secondly, as others have mentioned, you're pointing the environment variable to the 32-bit version. You need a 64-bit JDK. This will be installed at C:\Program Files\Java\jdk1.7.0_XX or similar, by default.
You can acquire a JDK installation from Oracle.
Here is the official installation instructions - http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html
The important thing is
Set JAVA_HOME to the location where jre or jdk is installed
Add %JAVA_HOME%/bin to your path variable.
Make sure you add these to "System Variables" and not in "User variables for xxx"
By default, c:\Program Files (x86) (environment variable ProgramFiles(x86))is used for 32-bit installations. 64-bit installations use c:\Program Files (environment variable ProgramFiles).
When I open a cmd box on my Windows 7 64-bit, I can issue the "set" command to get
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
This should be similar under Windows 8.
No JVM installation found. Please install a 64-bit JDK
This is looking for a 64bit version of the java JDK.
C:\Program Files (x86) is the x86 not 64bit.
Click the link below and make sure to download the x64 version.
Java SE Development Kit 7 Downloads
Then the folder path should be
C:\Program Files\Java\jre7
Try runing Android Studio as administrator after setting the JAVA_HOME variable!
It worked for me...
Same thing happened to me and it turns out that all I had to do was unblock the file. Go to the file properties and at the bottom where it tells you it's from another computer and is blocked, just unblock it. This may not be true for everyone but it probably is if the path code is exactly what it should be and still isn't working.
the solution is simple,
I think your java path contains /bin
C:\Program Files\Java\jdk1.8.0_181
just path to the folder of JDK
like C:\Program Files\Java\jdk1.8.0_181
don't forget to restart your IDE or Code Editor
I'm using a Windows .bat script and I set JAVA_HOME as C:/Program Files/Java/jdk1.6.0_32
when I do a java -version, it still shows the 1.3
How can I fix this? What am I doing wrong?
For me the issue was in my PATH variable, C:\ProgramData\Oracle\Java\javapath; was added by java windows install before my %JAVA_HOME%\bin;.
So I'd echo %JAVA_HOME% pointing to a JDK7 and java -version showing jdk8.
I'd to put %JAVA_HOME%\bin; before C:\ProgramData\Oracle\Java\javapath; so that java -version displays jdk7.
Try %JAVA_HOME%\bin\java -version
If you modify JAVA_HOME, it's usually better to invoke java with an absolute path (using JAVA_HOME) because the new binary is probably not in the path (and then Windows will load the wrong binary).
Make sure that the PATH environment variable is pointing to %JAVA_HOME%\bin.
Be sure not to mix the system variable path and the user variable system path. I feel OK in calling java without the absolute path (when I know how JAVA_HOME and PATH are configured).
Calling java -version from command line, causes cmd.exe to do the lookup on the "known" directories. "Known" means PATH environment variable. It seems that your PATH contains a java 1.3 bin folder, and not 1.6.
JAVA_HOME is another variable, that is used (for example, and not only) by java wrappers, or by scripts executing some java stuff.
Try doing this:
SET JAVA_HOME=C:/Program Files/Java/jdk1.6.0_32
%JAVA_HOME%/bin/java -version
Add quotes where needed.
I had similar issue,in my case , I had two versions java installed. it can be fixed by uninstalling one version of java completely from system.
Had a similar scenario today - two Windows 10 devices - both have JRE 1.6 & 1.7.
When typing
Java -version
One device shows 1.6 the other 1.7.
This was preventing me running a third party JAR to install some software on the device showing 1.6 (which worked fine on the device showing 1.7 when running java -version), using:
java -jar ThirdParty.jar
As the JAR needed to be run by 1.7.
Cause of this was in the PATH environment variable - one device had the location of 1.6 first in the PATH list, moving the 1.7 location above the 1.6 location resulted in consistency using Java -version and allowed me to install the software.
java -version will consult the paths in the special environment variable Path. You need to select the java version you want and move it upwards the latter (click "Move Up"). You probably have that reference to JDK 1.3 in Path above your addition of JDK 1.6. Since that's the first thing the OS finds, that's what it chooses to run.
Executing the command again with the same window opened after changing the environment variables will not work. Re-open it
I know this question is old but this was my case and I wanted to re-explain further, similar to #DanBot 's case