Tutorial: Your First Java Application
Most readers of the IntelliJ IDEA blog are long past writing “Hello World” applications, but there are plenty of people who haven’t yet taken that first step to writing a Java program. If you are one of them, this tutorial is for you.
(If you’re an experienced developer, show students, juniors, friends and family this tutorial to get them started).
Remember, IntelliJ IDEA Community is open source and completely free to use, and contains all the functionality you need to get started as a Java developer.
Once you’ve installed IntelliJ IDEA, you can watch the video and follow the tutorial steps together.
Some top tips, shortcuts and features from this video:
- To create a new class, press ⌘N on MacOS or Alt+Insert on Windows or Linux on the directory in the Project Window, and select “Java class”.
- When creating a new class, we can type the whole package path, separated by dots, followed by the class name, and IntelliJ IDEA will create the package and the Java file.
- Move onto the next line in a class file by pressing Shift+Enter. This will put us onto the next line in the correct position and won’t break the previous line the caret was on.
- To create a standard Java main method, we can simply type “main”. IntelliJ IDEA will generate a
public static void mainmethod for us with the correct parameters.
- Live templates save us a lot of typing. Use ⌘J, or Ctrl+J in Windows or Linux, to see a list of all live templates that are valid for the current context.
- Pressing Esc will always close a dropdown or dialog without making changes.
- If we press Ctrl+. (that’s a period/full stop) when a code completion item is highlighted, IntelliJ IDEA will complete our code with the selected item and place a dot after it.
- Go to the Run Window with ⌘4, or Alt+4 on Windows or Linux. Pressing this shortcut again will close the run window and put the focus back on the Editor.
- Java ARchive (JAR) files are called artifacts in IntelliJ IDEA.
- The keyboard shortcut ⌘; or Shift+Ctrl+Alt+s on Windows or Linux will open the Project Structure dialog.
- Press Shift twice to use Search Everywhere if you don’t know the shortcut for something.
- Pressing Ctrl twice brings up the Run Anything box, which is yet another way to run one of our configurations.
- Top 15 IntelliJ IDEA Shortcuts
- Tips for Writing Code in IntelliJ IDEA
- Code Generation and Completion (video)
Whether you’ve completed this tutorial or are looking for some other way to start learning Java, check out IntelliJ IDEA Edu, a version of IntelliJ IDEA that provides courses to teach you Java. Or you can install the EduTools plugin.
Subscribe to Blog updates
Thanks, we've got you!
The What, Why, and How of JPA Buddy in IntelliJ IDEA
Master JPA entity management with JPA Buddy in IntelliJ IDEA! Our latest article shows you how to simplify your workflow and reduce boilerplate code.
The Best of IntelliJ IDEA’s HTTP Client
In today's fast-paced tech world, easy and efficient management of web services and APIs is crucial. That's where IntelliJ IDEA's HTTP Client steps in, turning complex HTTP requests into a walk in the park. The HTTP Client is a feature-rich, text-based tool in IntelliJ IDEA Ultimate. It seamlessl…
Import Postman Collections to the HTTP Client
We know that many of you use Postman collections and want to stay in the flow while working with them. This means staying inside IntelliJ IDEA and not switching to a different app. Great news! You can now effortlessly transform Postman collections into .http and use them in the HTTP Client …
Profile on the Fly With the IntelliJ Profiler
At JetBrains, we believe that profiling should be simple and accessible to all developers, regardless of their level of expertise. That’s why the IntelliJ Profiler puts ease of use and seamless integration at the forefront of its mission. In previous releases, we introduced a range of features to s…