DEV Community

Cover image for πŸš€ Your First Java Project in IntelliJ IDEA: Creating a "Hello World" in Java πŸš€
Ricardo Caselati
Ricardo Caselati

Posted on

πŸš€ Your First Java Project in IntelliJ IDEA: Creating a "Hello World" in Java πŸš€

Ready to create your first Java program using IntelliJ IDEA? In this article, I'll guide you through the amazing journey of setting up a new Java project and running your very first "Hello World" program. Let’s keep it simple and practical! πŸ’»πŸ”₯

Step 1: Creating the Project

  1. On the welcome screen, click "New Project".
  2. Under New Project, select Java.
  3. Under Name, enter Hello World or the name of your project.
  4. Give your project a name, and for the "Location" field, you can leave the default path: ~/IdeaProjects.
  5. If you'd like, you can create a GitHub repository to version your code by checking the box labeled "Create a GitHub repository".
  6. In Build System, choose IntelliJ.
  7. In the JDK field, select version 17 (or the version of your JDK).
  8. Uncheck the "Add sample code" box to start the project from scratch.
  9. Click "Create".

ongratulations! You've successfully created a new Java project. πŸŽ‰

Image description

Step 2: Creating Your First Java Class

  1. Right-click the "src" folder, select "New", and then "Java Class".
    Image description

  2. A modal will appear where you can name your file, here "MyFirstClass". Choose a name for the Class.
    Image description

  3. The basic structure of the class will be generated automatically.
    Image description

Step 3: Writing the Code

Inside your new class, type "main" and hit Enter. IntelliJ IDEA will automatically create the main method signature for you.
Image description
press enter

Image description
IntelliJ IDEA will automatically create the main method signature for you.

Within the main method, add the following code:

System.out.println("Hello World");
Enter fullscreen mode Exit fullscreen mode

Image description

Step 4: Running the Program

Now, just click the green play icon to run your program. πŸŽ‰
Image description

Image description

That's it! Your first Java program is up and running, and you can start exploring the power of IntelliJ IDEA for Java development on Ubuntu. πŸš€

Ready to continue your Java programming journey? This is just the first step. Soon, we’ll dive into more features of IntelliJ IDEA and take your development skills further! See you next time! πŸ‘‹

Top comments (0)