Your First Java Project in BlueJ: Create, Compile and Run a Program
Create your first Java program in BlueJ step by step: make a project, add a class, write and compile the code, run main(), and create an object from the class – the essential first lesson for ICSE Class 9 Computer Applications.

Once BlueJ is installed, the next step is to write, compile and run your first Java program. This lesson walks you through the whole process. It is the same routine you will use for every program in ICSE Computer Applications and ISC Computer Science.
Step 1: Create a new project
- Open BlueJ and click Project → New Project.
- Choose a folder (for example
Documents), type the project nameMyFirstProject, and click Create.
A project is simply a folder that holds all your classes.
Step 2: Create a class
- Click the New Class button on the left.
- Type the class name
Hello. Class names start with a capital letter by convention. - Keep the type as Class and click OK.
An orange box labelled Hello appears. The stripes on it mean the class has not been compiled yet.
Step 3: Write the code
Double-click the Hello box to open the editor. Delete the sample code BlueJ inserts and type:
public class Hello {
public static void main(String args[]) {
System.out.println("Hello, Java4School!");
System.out.println("My first Java program in BlueJ.");
}
}Step 4: Compile
Click Compile in the editor window, or press Ctrl + K.
- If the message at the bottom reads "Class compiled – no syntax errors", you are ready to run.
- If there is an error, BlueJ highlights the line. The most common first-day mistakes are a missing semicolon
;, a missing closing bracket}, and typingsysteminstead ofSystem. Java is case-sensitive.
Step 5: Run the program
- Close the editor and right-click the
Hellobox. - Choose void main(String[] args) and click OK in the dialog that opens.
- The Terminal Window opens and shows:
Hello, Java4School!
My first Java program in BlueJ.Congratulations, you have run your first Java program!
Step 6: Create an object (the BlueJ way)
BlueJ lets you create objects without writing extra code, which is a great way to understand classes and objects. Add a second class:
public class Student {
String name = "Riya";
int marks = 95;
void display() {
System.out.println(name + " scored " + marks);
}
}Compile it, then right-click Student and choose new Student(). A red box appears in the object bench at the bottom. That is your object. Right-click the object and choose display(). The terminal prints Riya scored 95.
Key terms from this lesson
- Source code: the Java program you type, saved in a file such as
Hello.java. - Compiling: converting source code into bytecode (
Hello.class), which the Java Virtual Machine (JVM) runs. - main() method: the starting point of a Java program.
- Object bench: the area in BlueJ where the objects you create are shown.
What next?
Learn how to take input from the user with the Scanner class and BufferedReader, then practise with our ICSE Class 9 solved programs.
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.