JDK and PATH
Description
The JDK supplies javac and java.
Explanation
Adding the JDK bin folder to PATH lets the terminal locate those commands.
Example
java --version← Chapter 1 — Getting Started with Java
mixed
Install a Java Development Kit (JDK), not only a Java runtime. The JDK includes the compiler and tools needed to create programs.
An editor or IDE can speed up writing code, but learning the compile-and-run commands is useful. It makes the relationship between a .java file and a running program clear.
The JDK supplies javac and java.
Adding the JDK bin folder to PATH lets the terminal locate those commands.
java --versionUse two separate commands at first.
The class name after java has no .java extension.
javac FirstProgram.java
java FirstProgramA public class must use the same name as its file. If the file is FirstProgram.java, the public class must be FirstProgram; letter case matters.
public class FirstProgram {
public static void main(String[] args) {
String learner = "Rohan";
System.out.println("Java is ready for " + learner);
}
}Output
Java is ready for Rohan