In order to run any java program you need to setup jdk in your machine first. Today we’ll learn how to setup jdk in your machine. Here we’ll install jdk 20 which the latest as per oracle website. Below are the steps –
Download the java development kit from below url for windows https://www.oracle.com/in/java/technologies/downloads/
- Go to you downloads sections and double on the installer file as shown in below image –
3. Check for java installation – Open your command prompt and test the version of installed java
in above pic we can see java version 20.0.1 has been installed.
Execute java program via command prompt
- Create Java program – Create a folder in any location and create a file with name Test.java like below – 2. Compile java program – Now open command prompt at the same location where you have kept Test.java file and type command – javac Test.java , This command will compile your java program and generate a .class file
This .class file contains byte codes which can be run anywhere on any machine that’s beauty of java.
3. Run you .class file , in order to run .class file you need to use command- java test
Note- Please take care while typing , it’s case sensitive.