After installing java 11 on my system, runtime continues to be 1.8
Versions of java installed:
C:\Program Files\Java\jre1.8.0_201
C:\Program Files\Java\jdk-11.0.3
JAVA_HOME env variable value: C:\Program Files\Java\jdk-11.0.3
From command prompt running java -version command, expecting to see java 11 info but instead I see java 8.
Changing environment variable value does not change the results, rebooting doesn't seem to be doing anything.
C:\Users\user>java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) Client VM (build 25.211-b12, mixed mode)
expected is that java 11 runtime info is displayed
This just happened to me yesterday. Followed instructions to the letter, and still resulted in a different Java version (1.8.0) instead of the expected (11.0.5) for my downloaded version of JDK11. Funny enough, CMD prompt returned the correct Java version (11.0.5) for the 'javac -version' command, but not for the regular 'java -version' command. I was even told to try uninstalling the existing Java load by my IT expert, as he couldn't think of anything else to try... (I did not end up removing Java)
Turns out he did help me though, perhaps accidentally, but only realized this in hindsight. He told me to try moving the path variable
%JAVA_HOME%\bin
up to the very top of the displayed list of path variables found within the [Edit environment variable] window, for the PATH System Variable option. This did not work immediately, so we figured it had no effect. But I believe this failed because it turns out I had made an oversight when typing the variable in the first place. I had written the word "home" using small caps, instead of large caps. Once I realized my mistake and fixed it to show "HOME" in large caps, my CMD prompt returned the correct java -version of (11.0.5), which matched the javac -version command result.
Please note:
I then tried moving the %JAVA_HOME%\bin variable back to the bottom of the list, where it was originally created, and the java -version command no longer displayed v.11.0.5, but returned the original answer of v.1.8.0. So, I played around a bit and found that this variable needs to be ABOVE the following variable within the existing PATH window:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
Hope this helps others as it helped me!
In the Environment Variables move the JAVA_HOME above like the picture under:
And for Java 8 you can create JAVA8_HOME as in the picture
In system environment variables, append PATH to point to new JDK's bin folder, and remove the old entry
%JAVA_HOME%\bin
I solved this by updating the path in user variables instead of updating in system variables.
Currently I have:
JAVA_HOME = C:\Program Files\Java\jdk-11.0.6
and
path containing %JAVA_HOME%\bin
(in User variable)
I happened to encounter the same issue and this is how I had resolved it.
In cmd/terminal - type where java, this will return all installed versions of java in the system.
In my case, I had installed java 11 somehow some time ago (which I don't remember when). I then deleted the 2 directories of java 11 and Oracle java in the above list carefully. Then Added the JAVA_HOME
and PATH - %JAVA_HOME%\bin accordingly, then it worked.
1: Click on Start (Windows) button.
2: Write Environmental variables.
3: Select the item.
4: Go to Advanced tab.
5: Click Environmental Variables.
6: Look for the one called "path".
7: Check for the java 7 instalation and change it to the path of your Java 11 instalation (C:\Program Files\Java\jdk-11.0.3).
Just make sure that you have added the following path in both user variables and system variable .
C:\Program Files\Java\jdk-11.0.3
it will definitely work , if not try placing them at the top.
On Windows 10
Download JDK 11, run the .exe .
Follow the steps and the problem will be solved!
Copied the link where the jdk is stored.
e.g. :C:\Program Files (x86)\Java\jdk-11.0.12\ bin
System Properties -> Environment Variables -> (in System variables section) -> click the Path -> Edit -> in the path list (C:\Program Files (x86)\Common
Files\Oracle\Java\javapath), click next to it, the Edit text(click ok), now copy the path where the jdk is stored at the end of the path list .
On the same section(in System variables section) -> click New -> variable name : JAVA_HOME and Variable Value : C:\Program Files (x86)\Java\ jdk-11.0.12 (without file bin!!) -> click ok and close the windows.
Open CMD and run -> java - version and next javac -version.
I hope you found it useful.
Related
I have restarted my cmd line after setting the environment variables. Javac is set to version 11, but java is still set to 8?
I have set my path variables like this:
There are no entries from other java versions in my Path variables like in this question:
Installed Java 14 but Java -version still showing old Java
I have double checked that java.exe and javac.exe are in fact at location C:\Program Files\Java\jdk-11.0.7\bin:
I have read the other questions to this problem on Stackoverflow, but it was always that they set a wrong path, forgot to append /bin or had old paths to other java versions in their environment variables. I also tried reinstalling Java 11 and restarting the computer (as last idea). What else could I try?
This can be caused by multiple different reasons.
Try 'where java' and 'where javac' to see where they point to. You should thenbe able to find the exact path from where java and javac are being called in your environment.
Also ensure that you only have one jdk/jre in your Path. You can try to move %JAVA_HOME% to be the first element in the Path list.
Move %JAVA_HOME%\bin to the top and then check java -version in a new cmd window. Make sure you do it in both, User variables as well System variables. Check this to learn more about a similar problem and its solution.
You can also put in your system variables:
Click on Path
Edit
Click on New
Add the whole path something like: C:\Program Files\Java\jdk11.0_172\bin (this should be your path where the jdk is installed).
This will work and you will have java 11.
I made 2 changes in order to reflect java -version as Java11
Control Panel --> Edit environment variables for ur account
-->System Variables --> Path
Make sure %JAVAHOME%\bin should be on 1st place
Make sure C:\Program Files\Common Files\Oracle\Java\javapath should be on 2nd place.
why do I get this? How can I fix it?
C:\Users\ash>java version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.7.0_01', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
The accepted solution for Reinstalling ALL JDKs was a bit harsh.
I too experienced this problem and here is my 2 cents:
This problem started happening since I installed JDK 8 and still had JDK 6 installed. I need for different projects I'm working on.
I noticed I had both a User and a System %JAVA_HOME%, so I removed my User %JAVA_HOME% variable and left only the system one.
I also noticed that in my Oracle installation there was some Java executables and I believe those where the ones conflicting since both my Oracle and Java installations were in my %PATH% variable.
I removed all Java paths from my %PATH% Variable and only left the %JAVA_HOME%\bin at the start of the variable for avoiding any conflicts with the Oracle installation.
I had a similar issue after installing the java 1.8.
To fix this go to Advance System setting --> path and remove
C:\ProgramData\Oracle\Java\javapath;
Removing
C:\ProgramData\Oracle\Java\javapath;
work like charm
Reinstall JDK and set system variable JAVA_HOME on your JDK. (e.g. C:\tools\jdk7)
And add JAVA_HOME variable to your PATH system variable
Type in command line
echo %JAVA_HOME%
and
java -version
To verify whether your installation was done successfully.
I had a similar issue after installing the java 10.0
To fix this go to Advance System setting --> path and remove
C:\ProgramData\Oracle\Java\javapath;
I had to remove the Common Files javapath from the 'Path' that was conflicting, in order to make it work. Now thankfully the java -version works just fine.
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
Make sure your JDK Path variable is directing to the \bin folder and is at the top of the list, because it always uses the first match. By moving it to the top you can make sure that no other path is matched first.
If there's any other entry that has a file called java (such as C:\ProgramData\Oracle\Java\javapath) it will run the command against that file instead of the java file in your JDK. There's no need to reinstall the entire JDK unless your files are corrupt or damaged for some reason.
This problem generally occurs in Windows when your "Java Runtime Environment" registry entry is missing or mismatched with the installed JDK. The mismatch can be due to multiple JDKs.
Steps to resolve:
Open the Run window:
Press windows+R
Open registry window:
Type regedit and enter.
Go to: \HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\
If Java Runtime Environment is not present inside JavaSoft, then create a new Key and give the name Java Runtime Environment.
For Java Runtime Environment create "CurrentVersion" String Key and give appropriate version as value:
Create a new subkey of 1.8.
For 1.8 create a String Key with name JavaHome with the value of JRE home:
Ref: https://mybindirectory.blogspot.com/2019/05/error-could-not-find-javadll.html
I edited my path to put the Oracle JDK at the start of the path and that fixed it.
Problem:
We had the same problem in our Windows 2012 server. We used JAVA_HOME environmental system variable, an we used in the PATH this kind of settings: ...%JAVA_HOME%/bin;...
and no other java related settings was in the PATH.
The problem was we had a space at the end of the value of the JAVA_HOME variable. Like 'C:\Program Files\Java\Jdk 1.8.0_172 ' so the %JAVA_HOME%/bin meant 'C:\Program Files\Java\Jdk 1.8.0_172 \bin'. So because the value was split by space and the system tried to find java.exe at 'C:\Program Files\Java\Jdk 1.8.0_172' where it is obviously not.
Solution was: Delete the space from the end of value of the JAVA_HOME !
Uninstall Java from machine
Check Java folder is deleted from Program Files
Check Registry does not have any instance of Java
Open system Variables and delete the ONLY java path from PATH
Now install the new version again.
Set the Path in System Variables.
This process cleans up all the traces of java and then install fresh java.
Note: This issues occurs when there is multiple installation and uninstall done.
You could be using a 32 bit version of java on a 64 bit environment.
Export the registry hive form HKLM\Software\JavaSoft and import into HKLM\Software\Wow6432Node\JavaSoft. For 1.6 I only needed JavaHome and RuntimeLib values.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment]
"CurrentVersion"="1.6"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment\1.6]
"JavaHome"="C:\\Java\\jre"
"RuntimeLib"="C:\\Java\\jre\\bin\\client\\jvm.dll"
None of the above worked for me, unfortunately.
The error solved when I uninstalled the old JDK versions that were installed on my computer. I did it simply with the "Uninstall or change a program" tool (under the Control Panel).
I removed the "C:\Program Files (x86)\Heroku\bin" from PATH variable and the problem has gone. I think it is probably the Heroku require different version of Java. So check all directories in your PATH variable, remove the possible ones may have confliction.
If you face this error in cmd with another error as "could not find runtime environment" after you have done all settings in Environment Variable. Then you just need to run jre.exe in your jdk folder and reinstall it and then recheck it by java -version command. Hope it will help you.
rename file "C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"
CMD --> java -version
done.
In my case the regedit information was correct and the problem was solved by doing the below:
1) setting JAVA_HOME to jdk - set JAVA_HOME=C:\Program Files\Java\\bin
2) setting PATH to jre - set PATH="C:\Program Files\Java\\bin"
after adding the requirements path as illustrated up and deleting C:\ProgramData\Oracle\Java\javapath;. don't forget to reopen your editor.
Go to CMD and type the following:
SET PATH=C:\Program Files\Java\jdk1.8.0_291\bin
(here jdk1.8.0_291 represents your java version, it may differ for you)
I have java 7 and java 8 both installed on my windows system under C:\Program Files\Java
In the environment's path I specified the path of java 7 like this.
%JAVA_HOME%/bin where JAVA_HOME = C:\Program Files\Java\jdk1.7.0_17
But when I type javac -version it shows javac 1.7.0_17 which makes sense
but when I do java -version it shows
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
Any idea what may be the problem here?
Edit The installed folder :
And one more thing echo %PATH% has only one occurence of JDK that is for java 7 and no occurence for JRE found in it.
The issue is occuring most probably because you have a JRE in your PATH, before your JDK. This usually happens when we add JDK in the PATH and do not remove previously added JREs. Thus when you do java it points to the JRE and when you do javac it points to the other version/JDK (since the JRE does not have a javac in it)
If you don't have any JREs in your path, then you can copy your %JAVA_HOME% and paste it first in your path variable (make sure its before the system32 path).
A possible reason for why this works is explained in this answer:
JRE also puts a java.exe to c:\Windows\System32, that's how first command is resolved. Second command is resolved by the C:\Program Files\Java\jdk1.7.0_02\bin entry in your PATH variable.
If (and when) you are developing from the command prompt, you have to adjust the PATH variable so that C:\Program Files\Java\jdk1.7.0_02\bin is before c:\Windows\System32.
Go to Environment Variables in your windows machine.
In User Variables : Make sure to set
- Your user variable "JAVA_HOME" value to "C:\Program Files\Java\jdk-xxxx\bin"
where "jdk-xxx" is the version of your jdk.
In System Variable :
- Add same "C:\Program Files\Java\jdk-xxxx\bin" value to "Path" variable.
make sure to move the added value on top of all values.
Now try running java -version and javac -version.
worked for me. :) Here i've linked my screenshot
Ok, as you said that you have no JRE on your path, I assume that where java (if you have Windows 7) will give you C:\Windows\System32\java.exe.
Changing the java running
Try using the Java-Settings Dialog from the control panel to change the Java System Version, which is currently active. This should change the version java -version is returning. If this does not work, you will probably need to reinstall the Java version of which you want to run the java command, specify the path explicitly, write you own wrapper (which works if you are in the same directory as the wrapper) or place the JRE path before C:\Windows\System32\ onto your path (don't know if last option really is a good one).
A wrapper could look just like this:
#"C:\Program Files\Java\jre7\bin\java.exe" %*
and you can either name it java.bat (where it will work if you are in the same directory or put it in PATH before C:\Windows\System32\java.exe or you could name it java7.bat and put it anywhere on you path to be able to run the Java 7 JRE if you desire to do so.
A wrapper is also a good option if you want to change the JAVA_HOME when running.
Changing the javac running
If you want to run a different javac hit Windows + Pause and open the system dialog to change the PATH so it contains the path to your JDK 8 instead of your JDK 7. You will need to restart your command line for changes to show.
It's all about $JAVA_HOME system variable
In my case
for Windows
(moving jdk8 -> jdk9 -> jdk11) I had a garbage
left by jdk8 in PATH (before JAVA_HOME:"C:\path\java11")
so I just remove C:\ProgramData\Oracle\Java\javapath_jdk8 from system variables
// or place it below javapath_jdk11
for MAC edit .zshrc to have
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-???.jdk/Contents/Home"
To resolve such kind of environment issue I always believe on command whereis,
To do the same in windows download whereis.exe then set in path and execute the command
whereis java.exe
whereis javac.exe
You will easily find the exact path from which location java is being called in environment as well about javac.
Please check that you have replaced "C:\ProgramData\Oracle\Java\javapath;" with %JAVA_HOME%/bin in the PATH variable. This did the trick for me.
FOR LINUX USERS
if java and javac are showing different versions, then you can easily set them to the correct or same versions
step 1
sudo update-alternatives --config java
output :
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 manual mode
* 2 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 1081 manual mode
this will show the following results, start(*) indicates the javac version that your system is using. You can change it by selecting your required version.
step 2
sudo update-alternatives --config java
output :
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
* 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Now again you can select the version you want to run for java.
This way you can ensure that java and javac are having the same versions.
A side note with the accepted answer. I couldn't leave the trail of java-1.8.0, but I have installed java 17 and want java "17", so, I placed java 17 bin path in the first place (top most ) of path variables, Home variable and user variable, after that when I type in cmd : java -version, it also show java-1.8.0, then I restart cmd, restart Intellij ide, then I type java -version, then it shows :
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
and when I type :
C:\Users\dell>javac -version
It shows :
javac 17
Here is My path variables ScreenShots and command window :
Yes, it is true that in order to deal with mismatching versions we need to modify the PATH variable, and the where command (at least, in Windows) is very handy in finding out which program gets picked first.
There's, however, a twist:
when you look at the contents of yout PATH var after running, for example,
echo %path% > path.txt
you should be aware of the fact that PATH is actually composed of TWO sections: one is System PATH and the other is Current User PATH, and it is System Path that gets evaluated first but printed last.
So simply placing a path to your, say, brand-new JDK in front of everything will be useless as long as there's another place with older version somewhere in the System PATH.
This particular problem is especially common when you have entries such as
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath
in your System PATH. Simply move them to the tail of your Current User PATH section to make these entries the last ones within the search queue.
Check your JAVA_HOME variable under environment variables in Windows machine. Make sure It is pointing to the version that you want.
Next check java jdk path added into your "path" environment variable. Make sure It is the version that you want, Otherwise change this to your JDK version path and then move this to the top of the list of values in path variable. This should mark your desired version as the first choice and all issues will be resolved. I did so, and everything is good.
I have a similar case but both command javac --version show the old version of sdk. It shows "javac 11.0.8" even it should be "javac 19" which is the new version just be installed.
Go to search bar > type > env
click menu "Edit the system environment variables"
Advanced tab > click on button "Environment Variables..."
Under "System Variable" > select "Path" > click "Edit"
Looking for Java path such as "C:\Program Files\Java\jdk-19\bin"
Move the path using "Move Up" or "Move Down" button to the position before "%SystemRoot%\system32" Path
OK > OK
Try the command agian.
Hope this may help you guys.
I guess when you are writing javac, it is getting the value from jre7 which is currently being used by you for development purposes and when you write java version, it is getting the value of the version from the jre8 which is currently being used by the installed applications on your system because your JRE of the system is mentioned before the jre7 which you are using for development
I am programming through java 1.6 u_17, but i have JRE version 6 and JRE version 7 installed, so how to run my compiled program from JDK 1.6 to run through the JRE 6 only?
By Default, it runs my class files through JRE 7, how to change this behavior? Any idea of setting Class path in windows 7, as we does it for JDK.
The following is shown in my command prompt
E:\JAVA>javac -version
javac 1.6.0_17
E:\JAVA>java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)
This is for my SET command showing the Windows 7 environment paths
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Administrator\AppData\Roaming
ClassPath=C:\Program Files\Java\jdk1.6.0_17\bin\mysql-connector-java-5.1.5-bin.jar;
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=RANDMATE-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Administrator
JAVA_HOME=C:\Program Files\Java\jre6\bin;
LOCALAPPDATA=C:\Users\Administrator\AppData\Local
LOGONSERVER=\\RANDMATE-PC
NUMBER_OF_PROCESSORS=2
OS=Windows_NT Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.6.0_17\bin;C:\Program Files\Java\jre6\bin;C:\Program Files\MyS
QL\MySQL Server 5.1\bin;C:\Program Files\UltraEdit\;C:\Program Files\Jar2Exe Wizard\;C:\Program Files\Java\jre6\bin;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 6 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0605
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\ADMINI~1\AppData\Local\Temp
TMP=C:\Users\ADMINI~1\AppData\Local\Temp
USERDOMAIN=RANDMATE-PC
USERNAME=Administrator
USERPROFILE=C:\Users\Administrator
windir=C:\Windows
Looks like you are using Windows. Please go the Environment Variables and define a user variable as:
Right Click(My Computers) -> Advanced -> Environment Variables -> Add
Variable Name = JAVA_HOME
Variable Value = Root Folder of Java 1.6.0_17 installation
Also in the same screen, please check the PATH variable and make sure **bin** Folder of Java 1.6.0_17 installation is added in the path preferably in the beginning and remove the Java 7 from the path, if it is there.
I fix this problem by removing the java.exe in system32 folder. And then in the cmd the java command refer to the jdk set in the path enviroment variable.
java.exe is also available in C:\windows\system32 and in your case its version might be 1.7..
Since your path has C:\windows\system32 first. no matter how to set rest of the path, sonar always will load jre7. (refer to conf\wrapper.conf in Sonar directory, by default it has wrapper.java.command=java)
To fix this, change following property of the "wrapper.conf" file
wrapper.java.command=C:\Program Files\Java\jdk1.6.0_XX\bin\java
this will fix the issue irrespective of the path variables.
For those who had the same problem I suggest reading this thread:
https://superuser.com/questions/479889/wrong-java-version-being-reported
Quote of wmz: "To check what actually executes when you run 'java -version' run from command line:
for %I in (java.exe) do #echo %~$PATH:I"
Windows is checking the PATH variable to find an executable named java and using that to launch your application. It is quite normal in a development environment to have many installations (as you do). However this calls on you to manage your environment.
There are two ways for you to set environment variables in Windows. By going to My Computer > Advanced Settings > Environment Variables as described above, you can set a variabler to your JDK installation and then update the Path to find the bin directory in that installation. Youy have the choice of updating System variables (all users) or user variables (your account only).
Personally, I prefer not to use the system/user environment variables as this provides less flexibility. You can use bat files to explicitly set the Path for a specific moment in time, or indeed to override the JAVA_HOME to point to a different installation.
If you are using an IDE you can usually specify the target runtime on a per project basis. Alternatively, when running the program, provide the fully qualified path to the version of the java executable you wish to use.
I had same problem. Issue is that Java installation will copy a java.exe, javaw.exe and javaws.exe to windows/system32 directory. You must have installed JDK7 recently.
I just removed those files from Windows/System32 directory, however, kept older version in path. This solved the issue.
Try it out.
I was facing the similar problem. I am using Java 7 and Java 8 together. The Java 8 was installed in the machine but the 7 set-up I copied from another system. I have already set the JAVA_HOME & path pointing to 7. But when I try to echo %path%, it shows the Jdk 8 in the class path. after lots of google, I have found "C:\ProgramData\Oracle\Java\javapath" in the path. Removing the line from the path solved the problem.
Background
I'm using Windows 8.1 and I have both JDK6 and JDK8 installed. For development purpose, I needed to get java version "1.6.0_45" over the command java -version and javac 1.6.0_45 over javac -version. The second command was working as expected after setting JAVA_HOME as Home folder of JDK6 and adding %JAVA_HOME/bin% in Path. However the first command was still returning java version "1.8.0_71"
Troubleshooting
I could find the an entry in the Path environment variable which points to C:\ProgramData\Oracle\Java. This folder actually contains short cut to java.exe of JDK8.
Proper solution: Uninstall JDK 8
Workaround:Edit the short cut file so that it points towards java.exe inside %JAVA_HOME%\bin (Please replace the variable with actual folder)
set the PATH variable to your jdk6\bin directory. so that it will pick the javac and java from jdk6.
for setting the path variable go to Environment Variables.
After setting the path variables you need to restart your command prompt. (NOT the computer).
Just right click on MyComputer, then Advanced System Settings-->Environment Variables-->New
Then in the "variable Name" text field add the string "PATH" or if it already exists select PATH from the list and click edit then append the path for "bin" folder in java in program files to the Variable value text field followed by a semicolon (;), if not exits add the path of bin directory of your java folder in "Variable Value" field and click "OK".
If you want to check the result, open up a command prompt and type "java" then hit enter.
For windows 7(X86) path setting:
first step:
Mycomputer(Right click)-->properties-->advanced settings-->environment variales-->new
(user variable)
on this first varible name: "" JAVA_HOME "" value: "" C:\Program Files\Java\jdk1.7.0_45 ""
second variable name: "" PATH "" value: "" C:\Program Files\Java\jdk1.7.0_45\bin;.; ""
There are two types of path for java : Permanent & Temporary.
Here is the video tutorial describing how to set path for Java?
How to Set path for Java : https://www.youtube.com/watch?v=rM4Qq3Ua7Sk
This video tutorial will guide you in setting permanent and temporary path for Java. Simply follow the steps. This will work with any version of Java, JDK or JRE. In video I have used path of JDK, Simply copy path of JRE instead of JDK and rest is same.
OR read the tutorial here : How to Set path for Java : http://aatul.me/2011/08/24/how-to-set-path-for-java/
Hope this solutions will help you.
OS: Windows XP
I am using yuicompressor-2.4.2 to compress some CSS before uploading to my server.
But when I run it, the following exception appears:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/yahoo/platform/yui/compressor/Bootstrap (Unsupported major.minor version 48.0)
So I think it's because of the JRE.
I typed in the command:
cmd: java -version
And it says:
java version "1.3.1_01"
But it should say 1.6.0_16, since I have installed the latest version.
What should I do to make Java use the latest version instead of the old one?
Set the environment variable JAVA_HOME pointing to the directory where you have jdk 1.6.0
set JAVA_HOME=your_path_to_jdk1.6
set PATH=%JAVA_HOME%/bin;.;..;%PATH%
That's from a command window. Also you can do it from "My PC > Properties > Advanced > Environment variables"
Go to the system32 directory C:\Windows\System32 and delete following 3 files
java.exe
javaw.exe
javaws.exe
Now create a JAVA_HOME environment variable with value={root path of your jdk installation} and add the path till bin folder of your jdk in the PATH environment variable.
Open a fresh command prompt and run java -version to confirm the change
If you are using windows 7/10 go to command prompt and type
where java
Delete all the symbolic link shows below other than your actual installation directory.
Even if correctly added all the environment variables still sometime you can get wrong versions especially when you have multiple version installed in your system and want to switch between them.
On Windows, the JRE installs a java executable in the Windows directory, which should be the first java in your path. This is just a wrapper that looks in the Windows Registry to find the Java home directory (should be "%SystemDrive%\Program Files\Java\jre6" for Java 6) and runs using the libraries there.
Run %SystemRoot%\system32\java -version and see what you get. If that is Java 6, you have entries in your path before %SystemRoot%\system32 (which really should be first). Either fix your %PATH% variable, or you'll have to be explicit whenever you want to run this version of Java.
If running that instance of java doesn't report Java 6, its not installed (correctly). Uninstall and try installing again.
If you are having trouble because of the PATH, it is because you or some software you installed monkeyed with it; I recommend using the default which is to have system32 first. Everything works fine if the defaults are used.
Also, %JAVA_HOME% is not used by the JRE itself at all. Some common Java applications like tomcat and ant honor the %JAVA_HOME% setting, so perhaps yuicompressor does too. But this is a de facto convention, not a standard.
after where java in Command prompt
for example
where java
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files\Java\jdk-11.0.10\bin\java.exe
delete C:\Program Files\Common Files\Oracle folder
then close all terminals and write java -version in the terminal. it will show the right version
worked for me
You should modify your PATH environment variable:
My PC > Right click > properties > Advanced > Environment variables
And modify "Path"
Append at the end the path to your 1.6 installation:
;C:\jdk1.6.xxx\bin
and remove the previous one if present.
Add %JAVA_HOME%/bin to your PATH environment variable where JAVA_HOME is set to your JRE6u16 directory
I had the same problem. In System Properties > Environment Variables > System Variables > PATH make sure there is no other path associated with Java. To make sure, type in and check Java paths.
where java
Re-open Command Prompt and type java -version again. I hope this helps.
first by the following command, you should be aware of .exe file which runs when you type java in the command prompt
where java
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files\Java\jdk-11.0.10\bin\java.exe
as you see above , cmd first reads java from
C:\Program Files\Common Files\Oracle\Java\javapath
so go to the path above and remove java files .
then it should work fine
You should check your PATH environment variable. It is possible that some application you have installed has put its version of the jre in front of yours in the path.
It looks like the older Java version is still on the system PATH environment variable (where the OS looks for commands) or JAVA_HOME (where yuicompressor may look for the java executable)
How those variables are changed depends on your operating system.