Installing a Java JDK or JRE on Windows
suggest changeOracle publishes Windows installers for the JDK and the JRE. Other vendors publish Windows builds as well. The Oracle installation procedure is straightforward:
- Visit the Oracle Java Downloads page:
- Click on either the JDK button, the JRE button or the Server JRE button. Note that to develop using Java you need JDK. To know the difference between JDK and JRE, see here
- Scroll down to the version you want to download. (Generally speaking, the most recent one is recommended.)
- Select the “Accept License Agreement” radio button.
- Download the Windows x86 (32 bit) or Windows x64 (64 bit) installer.
- Run the installer … in the normal way for your version of Windows.
An alternate way to install Java on Windows using the command prompt is to use Chocolatey:
- Install Chocolatey from https://chocolatey.org/
- Open a cmd instance, for example hit Win+R and then type “cmd” in the “Run” window followed by an enter.
- In your cmd instance, run the following command to download and install a Java 8 JDK:
C:\> choco install jdk8
Getting up and running with portable versions
There are instances where you might want to install JDK/JRE on a system with limited privileges like a VM or you might want to install and use multiple versions or architectures (x64/x86) of JDK/JRE. The steps stay the same until you have downloaded the installer (.EXE). The steps after that are as follows (The steps are applicable for JDK/JRE 7 and above, for older versions they are slightly different in the names of folders and files):
- Move the file to an appropriate location where you would want your Java binaries to reside permanently.
- Install 7-Zip or its portable version if you have limited privileges.
- With 7-Zip, extract the files from the Java installer EXE to the location.
- Open up command prompt there by holding
ShiftandRight-Clicking in the folder in explorer or navigate to that location from anywhere. - Navigate to the newly created folder. Let’s say the folder name is
jdk-7u25-windows-x64. So typecd jdk-7u25-windows-x64. Then type the following commands in order :
cd .rsrc\JAVA_CAB10
extrac32 111
- This will create a
tools.zipfile in that location. Extract thetools.zipwith 7-Zip so that the files inside it are now created undertoolsin the same directory. - Now execute these commands on the already opened command prompt :
cd tools
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
- Wait for the command to complete. Copy the contents of
toolsto the location where you want your binaries to be.
This way, several JDK and JRE versions can be unpacked side by side.
Original post : http://stackoverflow.com/a/6571736/1448252