Before writing any java project, you need to install Java Development Kit(JDK) first. I use jdk1.7 in all my selenium webdriver example project.
So you can download jdk1.7 for learning purpose. After you download it, you can follow bellow instructions to install it step by step.
How to install JDK1.7 in windows
1. Click here to goto the download page.
2. Click link in above page to goto download area to download the latest jdk1.7 which version is jdk-7u80. Do not download jre, just download jdk. Before you can download, you must check “Accept License Agreement” radio box.
3. When you click the download link above, a dialog popup to let you save the java executable file to your local PC. If you are not login to oracle, you need login first. If you do not have an oracle account, you can also register one.
4. Double click the downloaded install file to install.
5. Click Run to start the installation process.
7. Keep default options unchanged and click Next button until the installation complete.
How to run java and set JAVA_HOME in windows
After you install JDK1.7, you can run java.exe by following command line.
C:\Java\jdk1.7.0_25\bin\java.exe
But it is not convenient to run java in this method for each time, so we need to add java bin directory in windows Path system environment variable.
First you need to add JAVA_HOME system environment variable.
1. Right click “My Computer” —> click “Properties” in popup menu then click “Advanced system settings” to open system properties dialog.
Click “Advanced” tab in “System Properties” dialog, then click “Environment Variables” button to open “Environment Variables” dialog.
2. Click “New” button in Environment Variables to add JAVA_HOME system environment variable. Set variable name to “JAVA_HOME”, set variable value to your jdk installed directory “C:\Java\jdk1.7.0_80”.
Click “OK” to save JAVA_HOME system environment variable.
Add java bin directory in “Path” system environment variable.
Edit “Path” system environment variable in “Environment variables” list. Add %JAVA_HOME% \bin to it. Seperate each bin path by semicolon.
Now you can run java command directly as following.
How to install Eclipse in Windows
Eclipse is a free java development IDE( integrated development environment) tool. You can use it just after download and unzip the zip file into a local directory.
- There has a few of eclipse packages used for different coding languages. Select the one you prefered. Since we just want to develope java project, so we can choose “Eclipse IDE for Java EE Developers” or “Eclipse IDE for Java Developers“. Choose correct eclipse version, 32 or 64 bit which match up your operating system.Download Page: http://www.eclipse.org/downloads/eclipse-packages/
2. Save the download eclipse zip file into your local PC.
3. Unzip the downloaded eclipse zip file into a folder you prefered. Wait until the unzip process finished. You do not need to install it, just double click “eclipse.exe” inside the extracted folder to start it. You can also create a short-cut for eclipse.exe file in your desktop, then you can run it easily.
4. After eclipse startup, you need to choose workspace folder to save all your project files. I prefer to choose a custom folder as my workspace folder because it is more easy to remember.
5. Now you can see following eclipse welcome page after click OK in above page.
How to configure custom JDK in eclipse
There is a default jdk installed with eclipse. You can follow below instruction to find it.
1.Open Eclipse. Click Window —> Preferences
2. Click Java —> Installed JREs in left panel of the popup dialog. You can see eclipse default installed jdk in right panel. If you want to add your custom installed jdk, just click Add button in right panel.
4. Choose “Standard VM” then click “Next” button.
5. Locate your custom jdk ( not jre ) home directory by click “Directory” button. (In my env, i use: C:\Java\jdk1.7.0_25)
6. Click “Finish” then you can see your custom jdk added in the list.
7. Check the checkbox before the jdk you just added. then click “OK”.
Now you has added your custom jdk in eclipse, and you can read following article to learn how to create your first java project and how to fix java Unsupported Exception.
How to create java project with myeclipse
How to fix java Unsupported major.minor version 51.0 Exception