How to Install the Java Software Development Kit. In this Article: Article Summary Downloading the Java Software Development Kit Installing on macOS Installing on Windows Installing from an Archive on Linux or Solaris Installing from a Package on Linux Community Q&A. In order to distribute a Java application, you want to avoid dependencies on third party software. Your app package should include the Java Runtime Environment, or JRE. In fact, the Apple Store requires the use of an embedded JRE as a prerequisite for Mac App Store distribution. The only Mac users that can stick with version 6 are those that need Java exclusively for use with installed applications, such as ChrashPlan, Wuala, Minecraft or Open Office.
Active1 year, 3 months ago
How can I change the Java Runtime Version on Windows.
I installed Java 7 for some tests, and now I need the old java6 as system default, but I don't want to uninstall the Java 7 (I need it for later tests). Can I change the system-used JRE in the control panel/Java/JRE tab? I can change/edit/add/delete the user-used version, but not the system-used.
Peter Mortensen14.4k1919 gold badges8888 silver badges117117 bronze badges
tomkpunkttomkpunkt74322 gold badges1111 silver badges2424 bronze badges
8 Answers
For Java applications, i.e. programs that are delivered (usually) as
.jar
files and started with java -jar xxx.jar
or via a shortcut that does the same, the JRE that will be launched will be the first one found on the PATH
. If you installed a JRE or JDK, the likely places to find the
.exe
s are below directories like C:Program FilesJavaSoftJREx.y.z
. However, I've found some 'out of the box' Windows installations to (also?) have copies of java.exe
and javaw.exe
in C:winntsystem32
(NT and 2000) or C:windowssystem
(Windows 95, 98). This is usually a pretty elderly version of Java: 1.3, maybe? You'll want to do java -version
in a command window to check that you're not running some antiquated version of Java.You can of course override the PATH setting or even do without it by explicitly stating the path to java.exe / javaw.exe in your command line or shortcut definition.
If you're running applets from the browser, or possibly also Java Web Start applications (they look like applications insofar as they have their own window, but you start them from the browser), the choice of JRE is determined by a set of registry settings:
More registry keys are created using this scheme:
i.e. one for the major and one including the minor version number. Each of these keys has values like these (examples shown):
.. and your browser will look to these settings to determine which JRE to fire up.
Since Java versions are changing pretty frequently, there's now a 'wizard' called the 'Java Control Panel' for manually switching your browser's Java version. This works for IE, Firefox and probably others like Opera and Chrome as well: It's the 'Java' applet in Windows'
System Settings
app. You get to pick any one of the installed JREs. I believe that wizard fiddles with those registry entries.If you're like me and have 'uninstalled' old Java versions by simply wiping out directories, you'll find these 'ghosts' among the choices too; so make sure the JRE you choose corresponds to an intact Java installation!
Some other answers are recommending setting the environment variable
JAVA_HOME
. This is meanwhile outdated advice. Sun came to realize, around Java 2, that this environment setting is - unreliable, as users often set it incorrectly, and
- unnecessary, as it's easy enough for the runtime to find the Java library directories, knowing they're in a fixed path relative to the path from which java.exe or javaw.exe was launched.
There's hardly any modern Java software left that needs or respects the
JAVA_HOME
environment variable.More Information:
..and some useful information on multi-version support:
Carl SmotriczCarl Smotricz56.3k1616 gold badges112112 silver badges156156 bronze badges
I use to work on UNIX-like machines, but recently I have had to do some work with Java on a Windows 7 machine. I have had that problem and this is the I've solved it. It has worked right for me so I hope it can be used for whoever who may have this problem in the future.
These steps are exposed considering a default Java installation on drive C. You should change what it is necessary in case your installation is not a default one.
C program for mac address. Suppose we have installed Java 8 but for whatever reason we want to keep with Java 7.
1- Start a cmd as administrator
2- Go to
C:ProgramDataOracleJava
3- Rename the current directory javapath to javapath_<version_it_refers_to>. E.g.:
rename javapath javapath_1.8
4- Create a javapath_<version_you_want_by_default> directory. E.g.:
mkdir javapath_1.7
5- cd into it and create the following links:
6- cd out and create a directory link javapath pointing to the desired javapath. E.g.:
mklink /D javapath javapath_1.7
7- Open the register and change the key HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime EnvironmentCurrentVersion to have the value 1.7
At this point if you execute
java -version
you should see that you are using java version 1.7:8- Finally it is a good idea to create the environment variable JAVA_HOME. To do that I create a directory link named CurrentVersion in C:Program FilesJava pointing to the Java version I'm interested in. E.g.:
9- And once this is done:
- Right click My Computer and select Properties.
- On the Advanced tab, select Environment Variables, and then edit/create JAVA_HOME to point to where the JDK software is located, in that case, C:Program FilesJavaCurrentVersion
MiaMia
Since Java 1.6, a java.exe is installed into %windir%system32 that supports a '-version' command line option. You can use this to select a specific version to run, e.g.:
will run a jar application in java 1.7, if it is installed.
See Oracle's documentation here: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html
JulesJules10.5k33 gold badges6363 silver badges109109 bronze badges
Once I updated my Java version to 8 as suggested by browser. However I had selected to uninstall previous Java 6 version I have been used for coding my projects. When I enter the command in 'java -version' in cmd it showed 1.8 and I could not start eclipse IDE run on Java 1.6.
When I installed Java 8 update for the browser it had changed the 'PATH' System variable appending 'C:ProgramDataOracleJavajavapath' to the beginning. Newly added path pointed to Java vesion 8. So I removed that path from 'PATH' System variable and everything worked fine. :)
Asanka SiriwardenaAsanka Siriwardena
Go to control panel --> JavaYou can select the active version here
Shazia TabassumShazia Tabassum
All you need to do is set the PATH environment variable in Windows to point to where your java6 bin directory is instead of the java7 directory.
Right click My Computer > Advanced System Settings > Advanced > Environmental Variables
If there is a JAVA_HOME environment variable set this to point to the correct directory as well.
David YoungDavid Young3,36022 gold badges1717 silver badges1818 bronze badges
Update your environment variables
Mac Choose Java Version For Program Directv
Ensure the reference to java/bin is up to date in 'Path'; This may be automatic if you have JAVA_HOME or equivalent set. If JAVA_HOME is set, simply update it to refer to the older JRE installation.
SyntaxSyntax1,38922 gold badges1616 silver badges3131 bronze badges
Verify Java Version
If you are using windows 10 or windows server 2012, the steps to change the java runtime version is this:
- Open regedit using 'Run'
- Navigate to HKEY_LOCAL_MACHINE -> SOFTWARE -> JavaSoft -> Java Runtime Environment
- Here you will see all the versions of java you installed on your PC. For me I have several versions of java 1.8 installed, so the folder displayed here are 1.8, 1.8.0_162 and 1.8.0_171
- Click the '1.8' folder, then double click the JavaHome and RuntimeLib keys, Change the version number inside to whichever Java version you want your PC to run on. For example, if the Value data of the key is 'C:Program FilesJavajre1.8.0_171', you can change this to 'C:Program FilesJavajre1.8.0_162'.
- You can then verify the version change by typing 'java -version' on the command line.
Java Version Test
Harvey LinHarvey Lin