📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Creating, Compiling, and Executing a Java Program
Step 1: Creating a Java Program
Welcome.java
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
Step 2: Compiling a Java Program
A Java compiler translates a Java source file into a Java bytecode file. Let's use the following command to compile Welcome.java file:javac Welcome.java
Step 2: Executing a Java Program
Let's use the following command to execute the bytecode:java Welcome
Java Program Development Process
Key Points
Caution
Tip
Note
Summary
- The Java source file name must match the public class name in the program. Java source code files must end with the .java extension.
- Every class is compiled into a separate bytecode file that has the same name as the class and ends with the .class extension.
- To compile a Java source-code file from the command line, use the javac command.
- To run a Java class from the command line, use the java command.
- Every Java program is a set of class definitions. The keyword class introduces a class definition. The contents of the class are included in a block.
- A block begins with an opening brace ({) and ends with a closing brace (}).
- Methods are contained in a class. To run a Java program, the program must have a main method. The main method is the entry point where the program starts when it is executed.
- Every statement in Java ends with a semicolon (;), known as the statement terminator.
- Reserved words, or keywords, have a specific meaning to the compiler and cannot be used for other purposes in the program.
- In Java, comments are preceded by two slashes (//) on a line, called a line comment, or enclosed between /* and */ on one or several lines, called a block comment or paragraph comment. Comments are ignored by the compiler.
- Java source programs are case sensitive.
- Java bytecode can be executed on any computer with a Java Virtual Machine.
Comments
Post a Comment
Leave Comment