Day 1: Introduction to Java Programming – Setting Up Your Environment & Writing Your First Program

RifatSeniabad
By -
0

Day 1: Introduction to Java Programming – Setting Up Your Environment & Writing Your First Program


Hello, future Java developers! 👋  

Welcome to Day 1 of  Edusofton’s 30-Day Java Course! Over the next month, we’ll take you from absolute beginner to confident Java programmer. Today, we’ll start with the basics: understanding Java, setting up your coding environment, and writing your first program. Let’s dive in!  

Why Learn Java?

Java is one of the most popular programming languages in the world, and here’s why:  

Platform Independence: Write once, run anywhere (thanks to the Java Virtual Machine).  

Object-Oriented: Build modular and reusable code.  

Robust & Secure: Ideal for enterprise applications, Android apps, web servers, and more.  

Step 1: Install Java Development Kit (JDK)

To write Java code, you need the JDK (Java Development Kit). Here’s how to set it up:  

1. Download JDK:  

   - Visit Oracle’s JDK download page

   - Choose the latest version (e.g., JDK 17 or newer).  

2. Install JDK:  

   - Run the installer and follow the prompts.  

   - Note the installation path (e.g., `C:\Program Files\Java\jdk-17.0.1`).  

3. Set Environment Variables (for Windows):  

   - Right-click This PCPropertiesAdvanced system settings → Environment Variables.  

   - Under System variables, edit Path and add the JDK’s `bin` directory (e.g., `C:\Program Files\Java\jdk-17.0.1\bin`).  


Verify Installation:  

Open Command Prompt or Terminal and type:  

```bash  

java -version  

```  

If you see the Java version, you’re good to go! 🎉  

Step 2: Choose an IDE (Integrated Development Environment)  

An IDE helps you write code efficiently. Popular choices:  

- Eclipse: [Download here]

- IntelliJ IDEA (Community Edition is free): [Download here]

- VS Code (with Java extensions): [Download here]

For simplicity, we’ll use VS Code in this course.  


Step 3: Write Your First Java Program 

Let’s create the classic “Hello, World!” program.  

1. Create a New File:  

   - Save it as `HelloWorld.java` (Java files end with `.java`).  

2. Write the Code:  

```java  

public class HelloWorld {  

    public static void main(String[] args) {  

        System.out.println("Hello, Edusofton Learners! 🚀");  

    }  

}  

```  

Explanation:  

- `public class HelloWorld`: The class name must match the filename (`HelloWorld.java`).  

- `public static void main(String[] args)`: The entry point of your program.  

- `System.out.println()`: Prints text to the console.  

Step 4: Compile and Run the Program

1. Compile:  

   - Open Terminal/Command Prompt in the file’s directory.  

   - Run:  

   ```bash  

   javac HelloWorld.java  

   ```  

   This generates a `HelloWorld.class` file (bytecode).  

2. Execute:  

   ```bash  

   java HelloWorld  

   ```  

Output:  

```  Hello, Edusofton Learners! 🚀  

```  


Congratulations! You’ve just written and executed your first Java program. 🎉  


Common Errors to Avoid  

Class name ≠ Filename: Ensure the class name matches the filename.  

Missing Semicolons: Java is strict about syntax (e.g., `;` after statements).  

Incorrect main method: The `main` method is case-sensitive and must be written exactly as shown.  


Day 1 Task

Modify the `HelloWorld` program to print your name or a motivational quote. Share your code in the comments below!  


What’s Next?

On Day 2, we’ll cover Variables, Data Types, and Basic Input/Output. Get ready to store and manipulate data!  


Got questions? Drop them in the comments, and we’ll help you out. Happy coding! 💻  


Stay curious,  

The Edusofton Team 


Tags:

Post a Comment

0Comments

Post a Comment (0)