تثبيت IntelliJ IDEA وجولة فيه
في هذا الدرس 11 موضوعات
هذا الدرس متاح حاليًا باللغة الإنجليزية فقط، ولم تُنشر نسخته العربية بعد.
Lesson Overview
You can now compile and run Java from a terminal, which is a fine way to understand what happens. But nobody builds a large program with Notepad and two commands. Programmers use an IDE, an integrated development environment: one application that combines an editor, a way to run programs, and many helpers.
In this lesson you install IntelliJ IDEA, the main IDE of this course, create a first project, run a class, read its output, and close the project properly. You also learn to find the four areas you will use all the time: the project tree, the editor, the run button, and the console.
In workshop terms, the JDK is the set of tools, and the IDE is the workbench built around them: good lighting, clamps, and labels, so that everything is in reach. The workbench does not replace the tools. It runs them for you, which is why a working JDK from lesson 2 is the starting point.
A warning about screens: IDE menus, button layouts, and even product editions change between versions. This lesson names the parts by their usual labels and gives keyboard shortcuts from the default settings. If something looks different on your screen, use the IDE's Help menu and its Find Action search, rather than guessing. Where a detail is not verified in official documentation, the lesson says so.
Learning Objectives
By the end of this lesson you will be able to:
- Explain what an IDE is, and name three things it does that a plain text editor does not.
- Install IntelliJ IDEA and choose the right download for your operating system.
- Create a new Java project and select the JDK for it.
- Add a class with a
mainmethod, run it, and find the output in the Run window. - Name the main parts of the IDE window: project tree, editor, run controls, console.
- Close a project and reopen it from the welcome screen.
- Explain why an IDE has its own JDK setting and why it may not use your
PATH.
Written Explanation
What an IDE gives you
A text editor only edits text. An IDE knows the language you are writing, and that knowledge appears as help:
- Error highlighting: a mistake such as a missing semicolon is underlined while you type, before you compile anything.
- Code completion: as you type a name, the IDE offers matching choices.
- Run and debug buttons: one click compiles and runs the program, with output shown in the same window.
- Project view: all the files of a project are displayed as a tree, with search and navigation.
None of this changes the language or the compiler. Under the hood the IDE uses the same JDK that you installed. It only presses the buttons for you. A learner who understands the manual route (javac, then java) will understand what the IDE does, and will be able to fix things when the IDE misbehaves.
Which edition, and where to get it
This course uses IntelliJ IDEA, made by JetBrains. Older course notes talk about the free Community Edition. JetBrains has since announced that, starting with version 2025.3, the two editions became one unified product, with the core features that Community offered remaining free to use. That is what JetBrains' announcement states, as reported in the sources listed below. Because download pages change, do this:
- Open the official JetBrains IntelliJ IDEA download page in your browser.
- Choose your operating system (Windows, macOS, or Linux) and your processor type if asked, such as Intel or Apple Silicon on a Mac.
- Pick the free option if the page offers a choice between free use and a paid or trial subscription. If a prompt asks you to sign in for a trial, you can usually skip it. Core Java work does not need the paid features.
- Run the installer, or on macOS drag the app to Applications, or on Linux follow the page's instructions for your system. Accept the defaults unless you have a reason to change them.
Paid features are not needed for this course, and if you are unsure whether a feature is free, ignore it for now.
The first launch: the Welcome screen
When no project is open, IntelliJ shows the Welcome screen. JetBrains documents that the Welcome screen appears when you close all open projects. From it you can create a new project, open an existing one, or pick a recent one.
Creating your first project
JetBrains' tutorial for a first Java application gives these steps. Read them as a pattern, because labels may change by version:
- On the Welcome screen click New Project. If a project is already open, use File, then New, then Project.
- In the dialog, choose Java and give the project a name, for example
hello-ide. Note the location: it is the folder where the project will live. Use the course folder from lesson 1. - Make sure the build system is set to IntelliJ. (Build tools such as Maven and Gradle come later in the course.)
- In the JDK field, select the JDK you installed in lesson 2. If the list shows it, choose it. If it is installed but not listed, use the option to add a JDK from disk and point to the JDK's root folder. If you do not have one, the dialog can download one, but you already have one.
- Leave the "add sample code" option off for this lesson, so that you create the class yourself and see every step. The option name may differ in your version.
- Click Create.
IntelliJ opens the project window and shows a project tree on the left, with a folder called src. Source files go there.
Adding a class and running it
In the Project tool window, select the src folder, then use the New menu (right-click, or Alt+Insert) to create a Java class. Name it ToolboxCheck. The IDE creates ToolboxCheck.java and it opens in the editor. The file name matches the class name, exactly as lesson 1 required. A new class file usually opens with the class declaration already written. Complete it:
public class ToolboxCheck {
public static void main(String[] args) {
System.out.println("Hello from the IDE.");
System.out.println("Java version: " + System.getProperty("java.version"));
System.out.println("Java home: " + System.getProperty("java.home"));
}
}main is the starting point: the Java launcher begins here. The System.getProperty calls ask the running JVM about itself. java.version is the version of the Java that runs the program, and java.home is the folder of the installation that runs it. These are standard system properties, so the program shows you which JDK the IDE actually used.
To run it, click the green arrow (Run) in the editor margin next to the class or the main method, and choose to run ToolboxCheck.main(). JetBrains' tutorial describes this gutter arrow. Many default keymaps also have a run shortcut, but shortcuts can differ, so use the arrow if you are unsure.
Reading the output: the Run window
A Run tool window opens at the bottom of the screen. JetBrains' tutorial says the program's output appears there, and that the last line reports an exit code, where 0 means the program finished successfully. For ToolboxCheck you see the three lines, and then something like Process finished with exit code 0.
If you close the window by accident, the documentation lists the shortcut Alt+4 to bring it back, and it appears only after you have run something. The same page lists Alt+1 for the Project window and Alt+F12 for the Terminal window, which is a command line inside the IDE that starts in the project folder.
A tour of the window
| Area | Where | What it is for |
|---|---|---|
| Project tool window | Left | The tree of folders and files in the project |
| Editor | Centre | Where you read and write code, with tabs for open files |
| Gutter | Left edge of the editor | Line numbers and the green Run arrows |
| Run tool window | Bottom | Output of your program, and the exit code |
| Terminal tool window | Bottom (via Alt+F12) | A shell inside the IDE |
| Menu bar | Top | File, Edit, View, and other menus. Some systems place it elsewhere |
| Problems and error marks | Editor and bottom | Red underlines and messages for mistakes |
Try breaking the program on purpose. Delete the final semicolon of one println line. The IDE underlines the problem, usually in red, and the message tells you what it expected. Fix it and run again. This is the error highlighting at work, and you have already saved yourself a compile cycle.
Closing a project, and coming back
Close a project through the File menu, using the Close Project item. In JetBrains' documentation I read, the Welcome screen is what you see after the last project closes. I could not open the page that describes the Close Project menu item itself, so check for it in your version's File menu, or use Find Action (see the Help menu for its shortcut) and type "close project". After closing, the Welcome screen lists your recent projects, so you can reopen hello-ide with one click.
Closing is not the same as quitting the application. Closing the project returns you to the Welcome screen, while quitting the application closes the whole IDE.
The IDE has its own JDK setting
One idea matters for later lessons. IntelliJ keeps a project JDK setting inside each project. It uses that JDK to compile and run, whatever your terminal's PATH says. So you can be in an odd state, such as a terminal that says "command not found" while the IDE works fine, or a terminal using a different Java version than the IDE. That is why ToolboxCheck prints java.home: it tells you the truth about the IDE's choice. To see or change the project JDK, look for the project settings in the File menu (often called Project Structure). Menu names can differ by version.
Examples
Example 1: Hello, from the IDE (simple)
Mia creates the project hello-ide, creates the class ToolboxCheck, and types the program from this lesson. She clicks the green arrow and sees:
Hello from the IDE.
Java version: <version>
Java home: <folder of the JDK>
Process finished with exit code 0The first line proves the program ran. The next two lines show which JDK was used, and she compares the version with the one printed by java -version in her terminal. They match, so the IDE and the terminal use the same JDK. The final line reports success.
Example 2: A typo and the error marks (practical)
Mia deletes the ; at the end of the first println. The IDE marks the line in red and a message appears when she hovers over it. She does not need to run the program to find out. She restores the semicolon and runs again. She then changes System.out.println to System.out.printn and sees a different kind of error: the IDE cannot find that name. Her takeaway is that an IDE's marks are hints, not decisions: she must still read the message and understand it. If the program does not run, the Run window shows the compiler's messages, in the same words as javac would use in a terminal.
Example 3: The IDE works, the terminal does not (realistic)
Sam installed a JDK through the IDE's Download JDK option (the dialog can do that). The IDE runs ToolboxCheck perfectly. But when Sam types javac -version in a Command Prompt, it says the command is not recognized.
There is no contradiction. The IDE downloaded its own copy of a JDK into a folder it manages, and the project uses that copy. No installer added it to the system PATH, so the terminal cannot see it. Sam has two choices: install the JDK in the normal way from lesson 2 and select it for the project, or add the downloaded JDK's bin folder to PATH as in lesson 3. The lesson is that an IDE and a terminal are separate programs with separate settings. The java.home line from ToolboxCheck tells Sam where the IDE's JDK is.
Backend Insight
Almost every professional backend developer uses an IDE, because large projects have hundreds of files, and the IDE's navigation, search, and error checking save hours. Backend projects are usually built with a build tool, and IDEs read the project's build files and configure themselves from them. The project JDK setting you met today usually comes from the build configuration in a real project, and team members must use compatible versions.
The IDE also hides a trap: because it runs the program for you, you may not know the command that really starts your service. On a server there is no IDE. The program starts from a command line, with java found through the server's PATH or a full path. So keep both skills. Use the IDE for speed, and remember what it does under the hood, so that you can reproduce a run in a terminal when you need to.
Finally, the IDE's built-in terminal and its Run window are the places where your program's output (and its logs) appear while you develop. Learning to read that output carefully, including the exit code, is the first debugging habit of a backend developer.
Common Mistakes
Mistake 1: Choosing the wrong JDK or none
- Incorrect: creating a project with no JDK selected, then wondering why nothing runs.
- Correct: select the installed JDK in the new project dialog and confirm it with the
java.homeline.
Mistake 2: Class name and file name do not match
The file must be named after the public class, with the same capital letters. Create classes through the IDE's New menu, which creates both correctly, and rename them with the IDE's rename function, not by editing the file in a file manager.
Mistake 3: Looking for the output in the wrong place
The output of System.out.println appears in the Run tool window, not in the editor and not in the project tree. If you do not see the window, use Alt+4 (after running at least once).
Mistake 4: Opening the wrong folder
To reopen a project, open the folder that contains the project's files (the one with src), not a folder above or below it. If the tree looks empty, you probably opened the wrong level. Closing a project never deletes its files.
Exercises
Try each exercise yourself before opening the solutions.
Level A: Foundation
A1. What is an IDE? Name three things it does that a plain text editor does not.
أظهر الحل A1
A1. An IDE is an application that combines an editor, run and debug tools, and language-aware help. It highlights errors as you type, it completes code, it runs a program with one click and shows its output, and it shows the project as a tree of files.
A2. Match each area with its job: Project window, editor, Run window, gutter arrow. Jobs: shows output, shows the tree of files, runs a class, holds the code you write.
أظهر الحل A2
A2. Project window: shows the tree of files. Editor: holds the code you write. Run window: shows output. Gutter arrow: runs a class.
A3. What does the exit code 0 at the end of the output mean?
أظهر الحل A3
A3. The program finished successfully. (Zero means success, according to JetBrains' tutorial. Other numbers usually indicate a problem.)
Level B: Application
B1. Install IntelliJ IDEA from the official page. Create a project called hello-ide with the JDK from lesson 2, add the class ToolboxCheck from this lesson, and run it. Write down the three output lines.
أظهر الحل B1
B1. Your output should be Hello from the IDE., then a line with the Java version, then a line with the JDK's folder. The last line is the exit code line. If the project JDK is the one you installed, the version matches your terminal.
B2. Introduce an error on purpose: remove a closing quotation mark in one string. Describe what the IDE shows before you run. Then fix the error and run again.
أظهر الحل B2
B2. The IDE marks the broken line in red and describes the problem, typically an unclosed string. Fixing the quotation mark removes the marks. If the version of the IDE shows different wording, that is fine. What matters is that the error is flagged before you run.
B3. Close the project and reopen it from the Welcome screen. Describe the steps you used, and confirm that the files are unchanged.
أظهر الحل B3
B3. Use the Close Project item in the File menu (or find it with the IDE's action search). On the Welcome screen choose the project from the recent list or use Open and select the project folder. The files should be unchanged, because closing does not delete or modify them.
Level C: Challenge
C1. Change ToolboxCheck so that it also prints the operating system name and the user's name, using System.getProperty("os.name") and System.getProperty("user.name"). Run it. Why would a backend developer want to know these values when diagnosing a server problem?
أظهر الحل C1
C1. Add two lines: System.out.println("OS: " + System.getProperty("os.name")); and System.out.println("User: " + System.getProperty("user.name"));. The values show the system the program really runs on. A server problem often depends on the operating system, the Java version, and the account that runs the service, and a program that reports them removes guesswork.
C2. ToolboxCheck reports a Java version different from the one that java -version prints in your terminal. Explain two reasons why that can happen and how you would make them agree.
أظهر الحل C2
C2. Reason 1: the IDE uses its own project JDK, and the terminal uses whichever JDK comes first on PATH. Reason 2: more than one JDK is installed and each tool picked a different one. To make them agree, select the same JDK in the IDE's project settings that the terminal uses, or fix the order of PATH entries. Confirm by comparing java.home from the program with the folder printed by where java or which java.
Mini Challenge
Make a one-page "IDE cheat sheet" for yourself, based on your own screen.
- Take a screenshot of the IntelliJ window with your
hello-ideproject open. Mark the four areas: project tree, editor, run controls, and console. - Write the steps you followed to create the project, in your own words, with the actual labels you saw.
- Write the step to close the project and how you reopened it.
- Add a "if the output does not appear" line: what you would check first.
- Add the
java.homevalue that your program printed, and say whether it is the same folder thatwhere javaorwhich javareports.
Check your work: another beginner could follow your steps on the same operating system, and your screenshot labels match what is really on screen.
Summary & Next Lesson
Key takeaways
- An IDE is an editor with helpers: error marks, completion, run buttons, and a project tree. It uses the same JDK and compiler as the terminal.
- JetBrains has unified IntelliJ IDEA into one product from version 2025.3, and its core features remain free. Check the official download page.
- Create a project, select the JDK, add a class with
main, run it with the gutter arrow, and read the output in the Run window. - Exit code
0means success. - The IDE keeps its own JDK setting. It can work when the terminal does not, and the reverse.
- Close a project from the File menu and reopen it from the Welcome screen.
Next lesson
You now have the main tool of the course. The next lesson, "VS Code as an alternative", introduces a lighter editor with Java support through extensions, so that you know the other common option and can choose one tool and stay with it.
Self-check
- Where do you see a program's output in IntelliJ?
- What does exit code
0mean? - Which setting tells the IDE which JDK to use for a project?
- Why can the IDE run Java while the terminal says "command not found"?
- Does closing a project delete its files?
أظهر الإجابات
- In the Run tool window at the bottom of the IDE (reopen it with
Alt+4after running something). - The program finished successfully.
- The project JDK setting, chosen when the project is created and changeable later in the project settings.
- The IDE uses its own project JDK setting, while the terminal uses
PATH. They are independent. - No. Closing only closes the project in the IDE, and the files remain on disk.
References
- JetBrains, Create your first Java application. Supports the New Project steps, the JDK choices (use a defined JDK, add one from disk, or download one), the green Run arrow in the gutter, the Run tool window at the bottom, the exit code
0meaning success, andAlt+4to reopen the Run window. The page assumed a recent Java version when I read it, and its sample used a compact source file; this lesson uses an ordinary class instead. - JetBrains, Run for the first time. Supports the statement that the Welcome screen appears when all projects are closed.
- JetBrains, Tool windows. Supports the default shortcuts
Alt+1(Project),Alt+4(Run), andAlt+F12(Terminal). - JetBrains, IntelliJ IDEA as a unified product and the unified release announcement. I saw these in search results and read only the search summary, not the full pages. They are the source for the statement that, from 2025.3, the Community and Ultimate editions became one product with the former Community features still free. Check the official page for the current licensing details.
- Oracle, System.getProperties (Java SE API)). The
java.version,java.home,os.name, anduser.namekeys are standard system properties. I know this from the API documentation but did not re-open the page in this session. - Not verified: the exact path of the Close Project menu item (the page I tried returned an error), the Project Structure menu name, and the run shortcut in the default keymap. The lesson hedges them.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.