Change your PATH variable so that it has the location of the jdk5/bin directory:
- Start -> Control Panel -> System -> Advanced
- Click on Environment Variables, under System Variables, find PATH, and click on it.
- In the Edit windows, modify PATH by adding the location of your jdk5/bin directory to the beginning. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the directory as the value.
- Close the window.
- Reopen Command prompt window, and run
java -version
Change your PATH variable so that it has the location of the jdk5/bin directory:
- Start -> Control Panel -> System -> Advanced
- Click on Environment Variables, under System Variables, find PATH, and click on it.
- In the Edit windows, modify PATH by adding the location of your jdk5/bin directory to the beginning. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the directory as the value.
- Close the window.
- Reopen Command prompt window, and run
java -version
In the command shell:
set JAVA_HOME=C:\jdk1.6.0u24
set PATH=%JAVA_HOME%\bin;%PATH%
That will temporarily set up the environment in the command shell. Maven, Ant, etc. will pick up on your new version of Java without having to go to the Control Panel repeatedly.
Tools like Eclipse should be able to select which JDK to use in their own configuration tools for use within their environments.
when latest version is installed in system it automatically set javapath in environment variable like "C:\ProgramData\Oracle\java\javapath".
Remove this from environment variables.
This suggestion may seem obvious, but I urge you to carefully consider this advice.
I have encountered this issue before, and frequently, it has been due to an overlooked entry within the long list of items making up the Windows Path. It is often an path entry where it is not immediately obvious that any of the java executables (javaw.exe, javaw.exe or javaws.exe) may reside. A common culprit is C:\ProgramData\Oracle\Java\javapath
You will therefore need to push upwards, your desired java/bin path above these. If in doubt, push it right to the top!
In the unlikely event that this does not work, then try making changes from within the java admin console (Control Panel --> Java --> Java tab --> View Button).
How do I switch between Java versions?
How to change default Java version in windows-latest?
install java updates
Switch between java versions with a command on Windows
Videos
So, I have two different versions of Java in my system, 8 and 16. Depending on the project, I need to switch between the two. Right now, I need to use 16, but when I run java -version I see, I'm still using "1.8.0_202".
I have changed my JAVA_HOME variable to point to the location of Java 16. Do I need to uninstall Java 8 in order to use Java 16? I'd rather not do that.
Try manually installing it.
This is what i normally do.
https://www.java.com/en/download/help/windows_m...
Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.
The first thing you need to do is determine which version of JAVA you need to download for your copy of Windows.
Which version of Java should I download for my 64-bit Windows operating system?
http://www.java.com/en/download/faq/java_win64b...
Troubleshoot installation
Uninstall older versions of JAVA you might have installed.
Press Windows key + R
Type: appwiz.cpl
Hit Enter
Scroll through the list of installaed programs
Select JAVA and click Change/Uninstall on the command bar
Restart your system
Disable your third party Antivirus you might have installed prior to updating.
Do a clean boot. http://support.microsoft.com/kb/929135
Reset your web browser to its default factory state and try again.
In Internet Explorer, click Tools or Alt + X
Click Internet Options
Go to the Advanced (tab)
Under Reset Internet Explorer settings, click 'Reset'
Try installing again
If you encounter download errors: 1305, 2755, 1606, see
http://www.java.com/en/download/help/error_inst...
Work around
http://java.com/en/download/help/index_installi...
Download the appropriate java setup file
Save it to your hard disk.
Disconnect your computer from the Internet, this includes disconnecting Ethernet cable or disconnect your wireless connection.
Install JAVA from the setup file.
Restart your computer
Reconnect to the Internet and JAVA should be installed.