Skip to main content

Command Palette

Search for a command to run...

Lab Sheet 2: Introduction to IDE

Updated
3 min read
Lab Sheet 2: Introduction to IDE
A
I co-founded🫆digizen (fighting internet chaos 🧠), building an AI app to tackle misinformation, and running ideaGeek to turn “I have an idea” into real startups. I also share tech + travel on YouTube (TechNomad & Rz Omar). I touch grass too 🌱… but mostly to debug life 💻

Lab 1: Introduction to NetBeans IDE

Objective: Familiarize yourself with the NetBeans IDE and its features.

Task 1: Installation and Setup

  1. Download and install NetBeans IDE from https://netbeans.apache.org/download/index.html.

  2. Launch NetBeans and create a new Java project named Lab1_HelloWorld.

  3. Write a simple Java program to print "Hello, World!" in the main method.

     public class HelloWorld {
         public static void main(String[] args) {
             System.out.println("Hello, World!");
         }
     }
    
  4. Run the program and observe the output.

Task 2: Exploring IDE Features

  1. Use the Syntax Highlighting feature to identify keywords, variables, and strings in your code.

  2. Introduce a Syntax Error (e.g., remove a semicolon) and observe how NetBeans underlines the error with a red wavy line.

  3. Hover over the error to see the explanation provided by the IDE.


Lab 2: Version Control with Git in NetBeans

Objective: Learn to use Git for version control in NetBeans.

Task 1: Initialize a Repository

  1. Create a new Java project named Lab4_VersionControl.

  2. Right-click the project and select Versioning > Initialize Git Repository.

  3. Commit the initial project state with the message "Initial commit".

    %[https://www.youtube.com/watch?v=TUAYiu2jej4]

This tutorial video is based on PHP, but you can practice this concept Init, Commit, Revert with Java

Task 2: Commit and View History

  1. Make a small change to the project (e.g., add a new class or modify an existing file).

  2. Right-click the project and select Git > Commit.

  3. Add a commit message (e.g., "Added new class") and commit the changes.

  4. View the commit history by selecting Git > Show History.

Task 3: Revert a Commit

  1. Make another change to the project and commit it.

  2. Revert to the previous commit by selecting Git > Revert from the history view.


Lab 3: Handling Errors

Objective: Identify and fix syntax, logical, and runtime errors.

Task 1: Syntax Errors

  1. Write the following code with intentional syntax errors:

     public class SyntaxErrorExample {
         public static void main(String[] args) {
             int x = 10
             System.out.println("Value of x: " + x)
         }
     }
    
  2. Use NetBeans to identify and fix the errors.

Task 2: Logical Errors

  1. Write a program to calculate the average of three numbers but introduce a logical error (e.g., divide by 2 instead of 3).

     public class LogicalErrorExample {
         public static void main(String[] args) {
             int a = 10, b = 20, c = 30;
             int average = (a + b + c) / 2; // Logical error
             System.out.println("Average: " + average);
         }
     }
    
  2. Debug the program to identify and fix the logical error.

Task 3: Runtime Errors

  1. Write a program that causes a runtime error (e.g., divide by zero).

     public class RuntimeErrorExample {
         public static void main(String[] args) {
             int a = 10, b = 0;
             int result = a / b; // Runtime error
             System.out.println("Result: " + result);
         }
     }
    
  2. Use exception handling to prevent the program from crashing.


Lab 4: Advanced Features

Objective: Explore advanced features like refactoring and build automation.

Task 1: Refactoring

  1. Create a class with a poorly named method (e.g., calc()).

  2. Use the Refactor feature to rename the method to calculateSum().

  3. Observe how all references to the method are updated automatically.

More from this blog

T

TechNomad

46 posts

TechNomad is mostly coding exercises, not long boring explanations 😌. I share what I teach and learn through hands-on problems—mainly for my students, but anyone can jump in. If you learn by doing (and breaking things), you’ll fit right in. Less theory, more “try this and see what happens.”