You can download the latest version of Java JDK from Oracle's Java site:
1
In java, we are going to download Java Development Kit (JDK). To download jdk visit this page and scroll down little you will see 3 options like JDK Download, Server JRE Download and JRE Download. Scroll down until you find Java SE 8 and download JDK.
2
All we need to do is, select first one. That is, JDK Download and click on Download button.
Now you will be taken to other page. In that page choose “Accept License Agreement” option and then look for Windows x86 and Windows x64 and click download button according to your OS version. (Windows, Mac, Linux, etc.)
For me, I’m having 64-bit OS version so I downloaded windows x64 setup file.
3
Once the download is complete, double click the file to begin the installation of JDK.
You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac , typically java_install_dir/bin and java_install_dir respectively.
If you are running Windows and installed the JDK in C:\jdk1.6.0_15, you would have to put the following line in your C:\autoexec.bat file.
set PATH=C:\jdk1.8.0_91\bin;%PATH%
set JAVA_HOME=C:\jdk1.8.0_91
Alternatively,
1. Open windows explorer by pressing Win+E key on your keyboard
2. Now in that window, Right-click on My Computer (This PC on Windows 8) and choose Properties option.
3. Click “Advanced system settings” and choose “Advanced” tab and then click on “Environment Variables…”
4. In System variables click New… button and fill
Variable name: PATH
Variable value: C:\Program Files\Java\jdk1.7.0_45\bin;
after filling press ok button.
Tip: Now use the copied path during installation here. Make sure you are pasting bin directory path, not the copied path.
Note: In System variable look for Path variable. If you found PATH variable, select it and click edit button and fill the above data. In variable value just add ; before adding new path.
Ex:
C:\Program Files\Java\jdk1.7.0_45\bin;C:\Program Files (x86)\QuickTime\QTSystem\
If you don’t find Path variable then you create new one.
5. Now we need to set Class Path for Java. To set Class path, go to User variables and click New…button
Now in pop up window enter
Variable name: CLASS
Variable value: C:\Program Files\Java\jdk1.7.0_45\lib
Tip: Now use the copied path during installation here. Make sure you are pasting lib directory path, not the copied path.
and click OK and again click OK to close Environment Variable window.
On Linux,
if the SDK is installed in /usr/local/jdk1.7.0_45 and you use the C shell, you would put the following code into your .cshrc file.
setenv PATH /usr/local/jdk1.7.0_45/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.7.0_45
Alternatively, if you use an Integrated Development Environment (IDE) Eclipse, then it will know automatically where you have installed your Java.