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
- On the welcome screen, click “New Project”.
- Under New Project, select Java.
- Under Name, enter Hello World or the name of your project.
- Give your project a name, and for the “Location” field, you can leave the default path:
~/IdeaProjects
. - If you’d like, you can create a GitHub repository to version your code by checking the box labeled “Create a GitHub repository“.
- In Build System, choose IntelliJ.
- In the JDK field, select version 17 (or the version of your JDK).
- Uncheck the “Add sample code” box to start the project from scratch.
- Click “Create”.
ongratulations! You’ve successfully created a new Java project. 🎉
Step 2: Creating Your First Java Class
-
Right-click the “src” folder, select “New”, and then “Java Class”.
-
A modal will appear where you can name your file, here “MyFirstClass“. Choose a name for the Class.
-
The basic structure of the class will be generated automatically.
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.
press enter
IntelliJ IDEA will automatically create the main
method signature for you.
Within the main
method, add the following code:
System.out.println("Hello World");
Step 4: Running the Program
Now, just click the green play icon to run your program. 🎉
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! 👋