Unit 1 · Java setup and first programs
javac and java.main method.A .java file contains source code. The compiler turns it into platform-independent bytecode in a .class file. The Java Virtual Machine (JVM) executes that bytecode. The JDK includes the compiler and development tools; the JRE conceptually describes the runtime needed to execute programs.
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}Save this as Hello.java. The public class name and file name must match. Run javac Hello.java, then java Hello. Do not include .class in the run command.
javac -Xlint:all Hello.java.static mean in main?println calls.Mastery task: Create a CourseCard program that prints the course code, title, prerequisite, and three habits for successful study.
1. Which tool converts Java source into bytecode?
javac compiles source code into bytecode.2. What must match the public class name?
Hello belongs in Hello.java.3. What does the JVM execute?
Draw or describe the path from Hello.java to program output, naming the JDK compiler and JVM.
Hello.java. javac Hello.java creates Hello.class bytecode. The JVM starts with java Hello, loads the bytecode, and executes main.Modify the example so it prints a three-line study plan. Compile and run it.
public class StudyPlan {
public static void main(String[] args) {
System.out.println("Read the lesson");
System.out.println("Write one program");
System.out.println("Review the errors");
}
}The file must be named StudyPlan.java.java --version and javac --version.CourseCard program that prints the course code, title, prerequisite, and three study habits.A strong submission shows matching class and file names, compiles without errors, and runs with java CourseCard. The explanation should state that the compiler produces bytecode for the JVM rather than machine code for one operating system; a compatible JVM can execute that bytecode on different platforms.