← All subjects
NewFree preview available
Coding · Any age, any level

Java from Beginner to Advanced: Programming with VS Code

Learn Java, one of the most used programming languages in the world and a language of school IT, using the free VS Code editor on your own computer.

★ New0 reviews0 learners
Created by GradesPal
Modules
3
Lessons
12
Study time
6h 45m

What you’ll learn

Set up a professional coding environment with VS Code and Java
Write programs with variables, input, decisions and loops
Break programs into methods and work with arrays and strings
Design classes and objects, and use encapsulation and inheritance
Handle errors, and save and load data in text files
Build a complete menu-driven marks manager

Workshop content

3 modules · 12 lessons · 6h 45m total

Level 1 · Beginner4 lessons
Set up and Hello, World30 min · Preview

Set up and Hello, World

Java5 min readRun it in VS Code

In this lesson

  1. What you need (all free)
  2. Installing
  3. Your first program
  4. What it all means
  5. Compile, then run
  6. More printing

Java is one of the most widely used programming languages in the world. It runs banking systems, Android apps and large company software, and it is used for Information Technology in many South African high schools. Learn Java and you learn ideas that carry over to almost every other language.

Note

Java is not JavaScript. The names are similar; the languages are not. JavaScript runs inside a web browser. Java programs run on your computer, so in this course you write and run your code in VS Code, a free editor used by professionals.

What you need (all free)

ToolWhat it is
JDK (Java Development Kit)The Java compiler and tools. Version 21 or newer
VS Code (Visual Studio Code)The editor you type in
Extension Pack for JavaAn add-on that teaches VS Code to understand Java

You need a Windows, Mac or Linux computer. Java cannot be set up properly on a phone.

Installing

The easy way (Windows and Mac): search for "Coding Pack for Java" from Microsoft. It installs VS Code, a JDK and the Java extensions together.

Step by step (any computer):

  1. Install a JDK. Search for "Temurin JDK" (from Adoptium), download the latest LTS version and run the installer. Accept the default options.
  2. Install VS Code from code.visualstudio.com.
  3. Open VS Code. Click the Extensions icon on the left (four squares), search for Extension Pack for Java and click Install.
  4. Close VS Code and open it again.

Check that it worked. In VS Code choose Terminal → New Terminal and type:

java -version

You should see a version number. If you see "not recognised" or "command not found", restart the computer and try again; if it still fails, reinstall the JDK.

Your first program

  1. Make a folder on your computer called java-course.
  2. In VS Code choose File → Open Folder and open it.
  3. Create a new file called Main.java. The capital M matters.

Type this exactly:

Main.javaJava
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Now click the Run button (a triangle at the top right), or the small Run link that appears above main.

The Terminal at the bottom shows:

Hello, World!

You are a Java programmer.

What it all means

CodeMeaning
public class MainEvery Java program lives in a class. Its name must match the file name: Main in Main.java
public static void main(String[] args)The main method: where the program starts. Type it exactly like this every time. You will understand each word by the end of the course
System.out.println("…");Print a line of text
{ }Braces mark where a block starts and ends
;Every statement ends with a semicolon
// …A comment: a note for people, ignored by Java

Java is case-sensitive: System is not system, and Main is not main.

Compile, then run

A computer does not understand Java directly. Two steps happen when you click Run:

  1. Compile. The compiler (javac) checks your whole program and translates it into bytecode.
  2. Run. The Java Virtual Machine (java) runs the bytecode.

If the compiler finds a mistake, the program does not run at all. VS Code underlines the mistake in red while you type. This strictness is helpful: many errors are caught before the program ever starts.

More printing

Java
System.out.println("Line one");
System.out.print("Same ");
System.out.print("line");
System.out.println();
System.out.println(7 * 6);

println moves to a new line afterwards; print does not. Numbers have no quotes, and Java works out the answer.

Try it

  1. Change the message to greet yourself by name.
  2. Print your name, grade and school on three lines.
  3. Remove a semicolon. Read the red underline and the error, then fix it.
  4. Rename the class to Hello without renaming the file. What does VS Code say?

Check yourself

What must the file be called if the class is "public class Marks"?

Marks.java. A public class and its file must have the same name, with the same capital letters.

What is the difference between print and println?

println ends the line after printing. print stays on the same line.

What are the two steps between your code and the output?

Compiling (javac turns the code into bytecode and reports errors) and running (the Java Virtual Machine runs the bytecode).

Variables and data types30 min
Input and arithmetic30 min
Making decisions30 min
Level 2 · Intermediate4 lessons
Loops30 min
Methods30 min
Arrays30 min
Strings30 min
Level 3 · Advanced4 lessons
Classes and objects30 min
Encapsulation and inheritance30 min
ArrayLists, files and exceptions30 min
Project: a marks manager75 min

Requirements

  • A Windows, Mac or Linux computer (not a phone or tablet)
  • Permission to install free software: VS Code and a JDK
  • No experience needed
  • Open to everyone: no age or grade requirement

Frequently asked questions

Do I need to install anything?

You need a computer with VS Code and Java, which are both free. Lesson 1 shows you how to set them up, step by step.

Can I buy only one level?

Yes. The course has three levels: Beginner, Intermediate and Advanced. You can buy the whole course or one level at a time.

How long does it take?

There are 12 lessons. Working about an hour a day, most learners finish in three to four weeks, but you can go at your own speed.

Who is this course for?

Anyone. The course starts from zero, so it suits school learners, university students and adults changing careers or learning for fun. There is no grade or age requirement.

Will I get a certificate?

Yes. Finish the lessons and the project to complete the course.

No reviews yet