1. Creating a new project step by step
A project in IntelliJ IDEA is not just a folder with files, but a whole container in which the IDE keeps everything related to your future application. A project contains:
- source code (files with the .java extension);
- project settings (for example, which Java version to use);
- external libraries (if needed);
- auxiliary files and resources.
Inside a project there is usually a folder src — this is the main place for your Java files. Everything that is not code is stored separately and does not get in the way.
Starting IntelliJ IDEA
On the welcome screen, click the big blue New Project button.
Configuring project parameters
Let's go through the main fields from top to bottom:
- Name: the name of your project. This name will also be used to create a folder on disk.
- Location: the path on your computer where the project will be stored. By default, IDEA suggests its
IdeaProjectsfolder. Leave it as is. - Create Git repository: lets you initialize a Git version control repository for the project right away. At this stage, to keep things simple, leave this checkbox unselected.
- Build system: a build system is a tool that automates compiling code, managing dependencies, and producing a runnable application:
- IntelliJ: IDEA’s built-in build system. Our choice.
- Maven/Gradle: powerful, standalone build systems; 99% of real-world projects use one of them.
- Add sample code: IDEA will automatically create a basic project structure and a class with a
mainmethod for us.
Installing a JDK from within IntelliJ IDEA
Now we’ve reached the point of installing a JDK.
- Since we haven’t installed one yet, the list will be empty. Our task is to download it right from here.
1. Click the drop-down list and choose Download JDK...
2. A small window will open:
- Version: choose the Java version. Our course supports version 25.
- Vendor: the distribution provider. As we agreed earlier, choose Amazon Corretto.
- Location: the path where IDEA will download and install this JDK. You can leave the default value.
3. Click Select.
All settings are done. Click Create.
IntelliJ IDEA will start downloading the selected JDK, then create the project structure and open the main editor window. You’ll need to wait a couple of minutes.
On first launch, you may see a notification in the bottom-right corner from the IDE suggesting you configure your antivirus, for example, “Microsoft Defender may affect IDE performance”. Feel free to click the Exclude folders button. IntelliJ IDEA will automatically add your project folder and its own system folders to your antivirus’s exclusions list.
2. A brief tour of IDEA
So, we’ve created a new project. Let’s figure out what we’re looking at.
1. Project — the main window for navigating the project structure.
2. The currently open file Main.java
3. Buttons for Run ▶ (launch) and Debug
4. Sidebar menu
- Services — a tab used to manage external services; you won’t need it at the beginning.
- Terminal — the command line (console) of your operating system (Windows, macOS, Linux), embedded right into the IDE.
- Problems — a panel that shows compilation errors and warnings as you write code. IDEA analyzes your code on the fly and underlines problematic places, often offering automatic fixes.
- Git — an icon in the form of a branching diagram. This panel is intended for working with the Git version control system.
3. Project structure
Now let’s look more closely at the Project tool window on the left. IntelliJ IDEA has created several important files and folders for us.
-
.idea— a service directory used by IntelliJ IDEA. It stores settings specific to this project.
You shouldn’t modify this folder manually or send it to other developers. It’s individual for each user. -
src— the most important folder in any Java project. The name is short for “sources”. This is exactly where all your code will live.-
Main.java— because we checked “Add sample code”, IDEA created this file for us. It’s a Java class with the “entry point” to the program — thepublic static void main(String[] args)method. This is where execution of any Java program begins.
-
-
.gitignore— a configuration file for the Git version control system. -
External Libraries— not a real folder, but a virtual representation of all external libraries attached to the project. Right now there is only one, but the most important library — our JDK.
4. Running the program
The most satisfying part is to run the program and see the result of your work (and not just errors).
At the top of the window, click the Run ▶ button. To its left you can see the name of the file that will start executing (in our case, Current File):
Alternative: right-click the file ▶ Run Run 'Main.main()'.
You will see the program’s output
Launch command (in red) — the command that IntelliJ IDEA constructed and passed to the operating system to start the program.
This is a direct invocation of thejava.exe executable from the very JDK we downloaded. This executable starts the Java Virtual Machine (JVM). The rest of the line after
java.exe consists of service parameters.
Program output (in blue) is the useful result produced by your code.
Exit code (in green) Process finished with exit code 0. This message is the final report on how the program finished.
- By convention, exit code 0 means the program successfully executed all its instructions from start to finish and terminated normally without any errors.
- Any other code signals that an error occurred during execution.
Always pay attention to this line. It’s your main indicator of whether your program “crashed” or finished correctly.
In addition, after the first run a new out folder appeared in the project structure on the left. It contains the compiled .class files — the very bytecode that the JVM executes.
Congratulations! You’ve just written and run your first Java program in a professional IDE.
How running a program works in IDEA
When you click Run, the following happens:
- IDEA compiles your code — turning
.javainto.class(bytecode for the JVM). - The JVM starts — the Java Virtual Machine begins executing the program from the
mainmethod. - Output is produced — everything printed via
System.out.printlnappears in the console.
All this magic happens in a couple of clicks — you don’t need to invoke the compiler manually or hunt for where the file was saved.
5. IntelliJ IDEA keyboard shortcuts
IntelliJ IDEA provides keyboard shortcuts for most commands related to editing, navigation, refactoring, debugging, and other tasks. Learning these hotkeys will help you work more productively without taking your hands off the keyboard.
You can view the shortcut combinations in the JetBrains documentation, with the ability to choose your OS.
Or check them right in IDEA. Menu → Help → Keyboard Shortcuts PDF.
6. Mistakes when creating your first project
Created a Java file outside the src folder
In the Java world there is a hard-and-fast convention: the src folder is the root from which all your project’s sources grow. The IDE and build systems expect to find code there.
Class and file names don’t match
The file must have the same name as the class (case-sensitive!). For example, Main.java for the Main class. If you name the file main.java (lowercase), the compiler will complain.
Missing or incorrectly written main method
The method must be exactly public static void main(String[] args). Even a single typo — and the program won’t start.
No JDK selected for the project
If no JDK is selected when creating the project, or the wrong path is chosen, IDEA won’t be able to compile the project. Check the settings via File → Project Structure → Project SDK.
Spaces and Cyrillic in paths
Although modern systems have become much more tolerant, the golden rule still applies: project and JDK paths should not contain Cyrillic, spaces, or special characters. It’s better to use only Latin letters and underscores.
Running the wrong class
If you have multiple classes with a main method, make sure you run the correct file (via right-click → ▶ Run).
GO TO FULL VERSION