The Java Development Kit (JDK) OR "Java Platform, trendy version (Java SE)" is available for writing Java applications. The JDK is freely available from sun Microsystems (now part of Oracle). The official website for JDK (Java SE) is oracle.com
What is "JDK" or "JRE" ?
JRE (Java Runtime) is used to running Java programs. JDK (Java Development Kit) comes with JRE plus the development tools (such as compiler and debugger), is need for writing (developing) as well as running Java programs. In other words, JRE is a subset of JDK. So you should install JDK with JRE to develop java applications.
1. How To Install JDK on Windows
Note : Please Uninstall the Older Virsion of JDK/JRE
Step 1A : Download The Setup of JDK
- Click the link to go to download page Download Setup
- Choose the right version of JDK for your operating system and download the setup file (JDK Installer)
Step 1B: Installation
Run the downloaded setup file, which installs both the JDK and JRE.
Accept the defaults and follow the screen instructions to install JDK and JRE.
Step 1C: Creating Environment Variable (JAVA_HOME)
- locate your java installation directory
If you didn't change the path during installation, it'll be something like
C:\Program Files\Java\jdk-17
You can also find a path through CMD with this comand :
where java
Windows 7 – Right click My Computer and select Properties > Advanced
Windows 8 – Go to Control Panel > System > Advanced System Settings
Windows 10 – Search for Environment Variables then select Edit the system environment variables- Under "System Variables", scroll down and select "Path" then Click on "Edit..."
- In the "Variable value" field, insert this line
"c:\Program Files\Java\jdk-x\bin
"
NOTE: Replacex
with your setup version, for example : jdk-9.0.1 or jdk-17
Step 1D: Verify JDK Installation
- Launch CMD
- Write javac then press enter
- If there is no error message, it means you have successfully installed JDK
2. Hello World Example in java
Now we are ready to create our first java program. we will create the hello world program as an example.
Steps
- Open notepad
- Copy code from below and paste in notepad
class Hello{
public static void main(String args[]){
System.out.println("Hello World");
}
} - Now save the file as Hello.java
Note: File name and class name must be the same, the first letter of file name and class name should be capitalized. - Now open CMD and write commands as step 5 and 6 to compile this java program then execute to see the result.
- Now compile => javac Hello.java
- Then execute => java hello
The output should be like this
Here is a video tutorial
Comments
Post a Comment