Your first Java Program
Brief History and Versions of Java
From the first version released in 1996 to the latest version JDK
21 available to the public since September 2023.
The latest version of Java is Java 21 or JDK 21 released on
September, 19th 2023.
JDK 21 is the latest long-term support release (LTS), replacing
JDK 17 which is the previous LTS of the Java SE platform.
Choose the x64 link and then download
This video will allow you to set as environment path
public — access specifier
Static — it allows the main function to be called without the need the instantiate a particular instance
void — return type
main — is the main java function
String args[] — is for command line arguments
System.out.println — is the print statement
class Ayushman {
public static void main(String[] args) {
System.out.println("Hello Ayushman ...");
}
}
command to compile a java file
javac firstcode.java
as you can see it created a .class file named Ayushman
now run the java file
java Ayushman
Congrats you have created the first file in java and then ran the code successfully