Lab Sheet 2: Introduction to IDE


Lab 1: Introduction to NetBeans IDE
Objective: Familiarize yourself with the NetBeans IDE and its features.
Task 1: Installation and Setup
Download and install NetBeans IDE from https://netbeans.apache.org/download/index.html.
Launch NetBeans and create a new Java project named
Lab1_HelloWorld
.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!"); } }
Run the program and observe the output.
Task 2: Exploring IDE Features
Use the Syntax Highlighting feature to identify keywords, variables, and strings in your code.
Introduce a Syntax Error (e.g., remove a semicolon) and observe how NetBeans underlines the error with a red wavy line.
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
Create a new Java project named
Lab4_VersionControl
.Right-click the project and select
Versioning > Initialize Git Repository
.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
Make a small change to the project (e.g., add a new class or modify an existing file).
Right-click the project and select
Git > Commit
.Add a commit message (e.g., "Added new class") and commit the changes.
View the commit history by selecting
Git > Show History
.
Task 3: Revert a Commit
Make another change to the project and commit it.
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
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) } }
Use NetBeans to identify and fix the errors.
Task 2: Logical Errors
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); } }
Debug the program to identify and fix the logical error.
Task 3: Runtime Errors
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); } }
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
Create a class with a poorly named method (e.g.,
calc()
).Use the Refactor feature to rename the method to
calculateSum()
.Observe how all references to the method are updated automatically.
Subscribe to my newsletter
Read articles from Arzath Areeff directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Arzath Areeff
Arzath Areeff
I co-founded digizen.lk to promote online safety and critical thinking. Currently, I’m developing an AI app to fight misinformation. As Founder and CEO of ideaGeek.net, I help turn startup dreams into reality, and I share tech insights and travel stories on my YouTube channels, TechNomad and Rz Omar.