Let’s jump into 5 - Hello World 🎉
🧪 Your First Java Program
Now that your Java tools are ready, it’s time to write your very first Java program! This tiny adventure checks that everything’s working — and gives your computer its first friendly greeting from you 🤗.
📂 Step 2: Create Your Robot Lab
- Create your
HelloWorldTest
folder on your desktop. - Inside VS Code, go to File → Open Folder… and choose your
HelloWorldTest
folder. - Create a
src
folder — this is where your Java magic will live! - If VS Code asks whether you trust the workspace, choose Trust and install any recommended extensions.
✅ Step 3: Prep for First Program
Make sure everything is installed and working — we’ll write our first program on the next page! 😄
✍️ Write the Code
- In your
src
folder, create a new file namedHelloWorld.java
- Type or paste in the following code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
🏃♀️ Run the Program
Use your terminal in VS Code
- Windows: choose PowerShell or Command Prompt via Terminal → New Terminal.
- macOS: open the integrated terminal or use the macOS Terminal app.
javac HelloWorld.java
java HelloWorld
If everything is set up, you’ll see:
Hello World!
🎉 Woohoo! That means Java is working, and you’re ready to start building robots!
That was confusing, what else is programming like?