DEV Community

Cover image for Java Newbie to Pro? Day 2 – How I Create My First Java Program
Nabil Mahmud
Nabil Mahmud

Posted on • Edited on

1

Java Newbie to Pro? Day 2 – How I Create My First Java Program

If you read my previous post, you know that Day 1 was all about setting up my Java development environment. Now that everything is ready, it’s time to write some actual Java code! 🚀

To save myself some keystrokes (and give you a more visual guide), I’ll be using video clips from Caleb Curry’s Java tutorial—because, let’s be honest, watching something is sometimes way easier than reading long explanations! 😁

Creating a New Java Project in Eclipse

I followed the steps in this video clip to create a new Java project using Eclipse. Since the clip is from Caleb's original tutorial, I had to make a few small tweaks because Eclipse’s default project setup has changed slightly over time. But here’s a challenge for you—try figuring out the tweaks yourself! A little bit of problem-solving will add to your technical sophistication and serve you well on your programming journey. 😉

Creating the First Java Program

I followed the steps in this clip to create my very first Java program—smooth sailing, no hiccups! The process involves creating a Java class using the IDE. In Java, the class name must match the filename that contains it. So, in this case, I created a file named MySweetProgram.java, which holds a class with the same name: MySweetProgram.

In the next post, I'll give a brief and superficial introduction to classes. For now, just think of a class as a container that holds different pieces of your program.

Tweak and Run the First Java Program

After setting up the program following the clip above, I used this clip to tweak the code and finally run it—successfully printing the phrase "Hello there!" to the console. Btw,these are the lines of our first program:

public class MySweetProgram {
   public static void main(String[] args) {
      System.out.println("Hello there!");
   }
}
Enter fullscreen mode Exit fullscreen mode

👉 "In the next post, we’ll learn more about the nitty-gritty of the program we've just finished writing.

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.