1. Introduction to IntelliJ IDEA
1.1 Jetbrains company introduction
JetBrains is a global software provider that builds intelligent tools for software developers and their teams to increase productivity. The company is headquartered in Prague, Czech Republic, and has 12 offices worldwide. JetBrains currently employs more than 1,800 people and continues to grow without external financing. Its product catalog covers every stage of the software development cycle as well as major technologies, programming languages, and educational processes.
JetBrains official website https://www.jetbrains.com JetBrains Chinese official website https://www.jetbrains.com.cn
Jetbrains has released more than 34 products since its establishment and has more than 12.8 million users.
- IDE for developers
-
IntelliJ IDEA — The leading Java and Kotlin IDE
-
PyCharm — Full-stack Python IDE
-
PhpStorm — Efficient and intelligent PHP IDE
-
RubyMine — Smart Ruby and Rails IDE
-
WebStorm — the smartest JavaScript IDE
-
AppCode — a smart IDE for iOS/macOS development
-
CLion — Cross-platform C/C++ IDE
-
DataGrip — SQL IDE
-
GoLand — Cross-platform Go IDE
-
Rider — Cross-platform .NET IDE
-
DataSpell — IDE for data science
-
Fleet — the next generation IDE built by JetBrains
-
Aqua — a powerful test automation IDE
No matter which platform or language you use, JetBrains has the right development tools.
-
Code With Me — real-time collaborative development
-
Toolbox App — Control panel for tools and projects
Languages and frameworks for developers
-
Kotlin — modern, concise, and safe programming language
-
Ktor — An asynchronous framework for creating microservices, web applications, and more
-
Compose Multiplatform — Kotlin declarative multi-platform UI framework
-
MPS — create your own domain-specific language
Team oriented
-
Space — a complete software development platform
-
TeamCity — powerful continuous integration out of the box
-
Upsource — code review, project analysis
-
Datalore — a collaborative data science platform for teams
-
YouTrack — Powerful project management for all teams
-
Hub — YouTrack and TeamCity connector
-
Qodana — Your favorite code quality platform for CI
1.2 Introduction to IntelliJ IDEA
IntelliJ IDEA is the leading IDE for Java and Kotlin development. It has a suite of features that help increase productivity, including smart coding assistance, reliable refactoring, instant code navigation, built-in developer tools, web and enterprise development support, and more.
1.2.1 Latest changes in IntelliJ IDEA
I want to know what changes have taken place in the latest version of IntelliJ IDEA, and what new functions and features have been added. Then you can access the latest changes in IntelliJ IDEA
In IntelliJ IDEA 2023.1, we have made a lot of improvements to the new UI based on valuable feedback from users. We've also implemented performance enhancements to import Maven faster and provide IDE functionality earlier when a project is opened. The new version provides a streamlined submission process with background submission checking. IntelliJ IDEA Ultimate now supports navigation of Spring Security matchers and request maps.
1.2.2 IntelliJ IDEA functions
Want to know the following main functions of IntelliJ IDEA
-
Developer Ergonomics
-
Deeper code insights
-
Quick navigation and search
-
Run, test and debug
-
Built-in tools and integrations
-
version control
-
JVM framework
-
Web development
-
deploy
-
Remote development and collaboration
Then you can access IntelliJ IDEA functionality
1.2.3 IntelliJ IDEA resources
IntelliJ IDEA resources provide a rich knowledge base, videos, blogs, documents and some commonly used quick access
-
Getting Started, Creating Java Applications, Mastering Shortcuts, Managing Plugins, Integrating with Git, Researching Editor Basics, Migrating from Eclipse, and Migrating from NetBeans are provided in the Knowledge Base, which is actually from the IntelliJ IDEA Help
-
The video provides tips for using IntelliJ IDEA
-
Quick access allows you to jump to shortcut keys, IntelliJ IDEA help , plug-in market , and community forums
1.2.4 IntelliJ IDEA shortcut keys
If you want to use IntelliJ IDEA efficiently, you must master the IntelliJ IDEA shortcut keys
Since the keyboard layouts of Windows, Linux, and macOS are different , their shortcut keys are also different.
IntelliJ IDEA shortcut keys for Windows and Linux
IntelliJ IDEA shortcut keys for macOS
1.2.5 IntelliJ IDEA plug-in market
In addition to many built-in plug-ins, IntelliJ IDEA also supports a large number of third-party plug-ins, and most plug-ins are free to use.
Search for the desired plug-in in the IntelliJ IDEA plug-in market, download it, install it and use it.
1.2.6 IntelliJ IDEA Help
If you have any problems in the process of using IntelliJ IDEA, you can visit IntelliJ IDEA Help to solve it. It is a detailed manual about IntelliJ IDEA officially provided by Jetbrains , which is better than any book about IntelliJ IDEA on the market .
In the help of IntelliJ IDEA, functions about all aspects of IntelliJ IDEA are provided, such as installation, uninstallation, configuration, project configuration, operation, debugging, deployment, testing, analysis, version control, remote development, integration tools and other languages, Framework, platform support and usage.
2. Installation and uninstallation of IntelliJ IDEA 2023.1 for Windows
2.1 Windows version IntelliJ IDEA 2023.1 download
- Click Download to jump to the download page
IntelliJ IDEA download address https://www.jetbrains.com/idea/download
At this time, the corresponding version of IntelliJ IDEA will be selected based on the version of the operating system currently used.
IntelliJ IDEA supports mainstream desktop operating systems, including Windows, macOS, and Linux (Ubuntu)
Since you are currently using Windows 11, the Windows version of IntelliJ IDEA is selected by default.
However, it should be noted that when you click Download, the Intel chip version will be selected by default.
- System requirements lists the relevant requirements for using IntelliJ IDEA
However, I suggest that if you use IntelliJ IDEA for Java project development, then refer to the following configuration
-
64th placeWindows10, Windows11
-
Intel i9 and above CPU, such as 13900k, 13980hx
-
64GB and above memory
-
2TB and above SSD
- Other versions You can download other versions, such as 2022.3.3, etc.
- Download IntelliJ IDEA Ultimate
Normally, Jetbrains releases three major versions of IntelliJ IDEA every year . For example, 2023 will be Intellij IDEA 2023.1, Intellij IDEA 2023.2, and Intellij IDEA 2023.3.
IntelliJ IDEA is divided into two versions: IntelliJ IDEA Ultimate and IntelliJ IDEA Community Edition
Each major version of IntelliJ IDEA Ultimate can be tried for free for 30 days, and payment is required after 30 days.
IntelliJ IDEA Community Edition can be used permanently for free, but its functions are relatively simple , so we will use IntelliJ IDEA Ultimate when developing projects in the company
When you click Download, the browser will automatically start downloading IntelliJ IDEA
After the download is successful, you can see ideaIU-2023.1.3.exe in the download directory (C:\Users\liuguanglei\Downloads)
If your Windows system uses an ARM chip instead of an Intel chip , then you need to switch to the .exe (ARM64) download
However, most Windows systems should use Intel chips (processors) , which can be viewed in Master Lu’s hardware parameters.
2.2 Installation of IntelliJ IDEA 2023.1 for Windows
- Double-click ideaIU-2023.1.3.exe
In the User Account Control popup , do you want to allow this app to make changes to your device? Click Yes to start the installation of IntelliJ IDEA
- Click Next
- Select installation path
The default installation path is C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.3. I use the default path to install here.
If you want to install to another path, click Broswe... , and then select the path you want to install, but pay attention to avoid Chinese and spaces in the directory
- Click Next
- Configure installation options
① Create a shortcut to IntelliJ IDEA on the desktop
② Add the bin directory to the PATH environment variable, but you need to restart the system so that you can enter idea in the terminal to start IntelliJ IDEA
- Click Next
- Select the start menu folder
The start menu folder defaults to Jetbrains.
- Click Install to start the installation
The entire installation process takes about 1-3 minutes depending on the computer configuration.
installing
- The installation is complete
After the installation is complete, select Reboot now and click Finsh to restart the computer.
After the restart is successful, you can see the IntelliJ IDEA shortcut on the desktop.
You can see the IntelliJ IDEA 2023.1.3 installation directory in C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.3
Since IntelliJ IDEA needs to be used frequently to develop Java projects in the later stage, it is recommended to fix it on the taskbar. The advantage of this is that you can directly click IntelliJ IDEA on the taskbar to start .
Windows 11 can drag desktop shortcuts directly to the taskbar.
If you want to pin other unstarted programs on the desktop to the taskbar, just select the desktop icon and drag it to the taskbar.
2.3 First use of IntelliJ IDEA 2023.1 for Windows
Since IntelliJ IDEA requires a license before it can be used for the first time , here is how to get a free 30-day trial by registering and logging into your Jetbrains account.
- Start IntelliJ IDEA
Double-click the IntelliJ IDEA shortcut on the desktop to start it
Or select IntelliJ IDEA and right-click to open it
- Agree to the User License Agreement
If you have agreed to the user agreement when installing IntelliJ IDEA, you do not need to agree to the user agreement even after uninstalling and reinstalling IntelliJ IDEA. However, if it is the first installation of a new system, you can only see Agree to the User Agreement. In the window, check I confirm that I have read and accept the terms of this User Agreement and click Continue.
- data sharing
-
If you do not want to share data, click Don't Send
-
To share data, click Send Anonymous Statistics
I won't share data here, so click Don't Send
- Get License
Windows Defender Firewall may block some functions of this application before obtaining a license . You need to select a private network and a public network, and click Allow access
There are two ways for IntelliJ IDEA to obtain a License.
The first is to click Activate IntelliJ IDEA
When you click Activate IntelliJ IDEA has 3 ways to obtain the License
Method 1: Obtain License from Jetbrains account
This method requires registration and login to Jetbrains account
Method 2: Fill in the Activation Code to obtain the license
Method 3: Fill in the License Server to obtain the license
Click Buy license to jump to the address for purchasing the IntelliJ IDEA license . If conditions permit, it is recommended that you support the genuine version.
The second way is to click Start trial
We choose the second method here, click Start trial, and try it for free for 30 days after registering and logging in to your Jetbrains account.
①Select Start trial
② Click Register… to register a Jetbrains account
Then open the Jetbrains Account page in IntelliJ IDEA
① Fill in your email address
② Click Sign Up
Then Jetbrains will prompt Thank you for registering your JetBrains account! Please follow the instructions we just emailed you
Then log in to the email client (such as NetEase Mailbox Master ), check the Complete your account registration email sent to you by Jetbrains, and then click Confirm your account to jump to the registration page.
After filling in the relevant account information on the registration page, click Submit to submit.
After successful registration, JetBrains Account will jump to the license page.
Now return to IntelliJ IDEA Licenses and click Log in to Jetbrains Account... Log in to Jetbrains account
Then fill in the account information on the Jetbrains Account page and click Sign In to log in to the Jetbrains account
After successful login, the page will prompt that the authorization is successful. You can close this page and return to the IDE.
And IntelliJ IDEA will automatically log in to the account you just registered.
Then click Start Trial to start the trial
In this way, you can see the license information of IntelliJ IDEA in the Licenses window, which can be used until August 3, 2023, which is a one-month trial.
Then click Continue to close the Licenses window.
You can see the IntelliJ IDEA welcome window, which means you can use IntelliJ IDEA to develop Java projects.
2.4 Uninstall IntelliJ IDEA 2023.1 for Windows
2.4.1 Uninstall instructions for IntelliJ IDEA 2023.1 for Windows
Q: When do I need to uninstall IntelliJ IDEA?
A: ① Uninstall the old version of IntelliJ IDEA before using the new version of IntelliJ IDEA ② Uninstall IntelliJ IDEA when no longer using IntelliJ IDEA
Required to uninstall IntelliJ IDEA
-
Uninstall IntelliJ IDEA application
-
Delete the specified directory
-
Delete registry key
2.4.2 Uninstall the IntelliJ IDEA application
- Open the installed app
Right-click on the Start menu and left-click on the installed application
You can view the applications installed on the system
- Search IntelliJ IDEA
- Click Uninstall and Confirm Uninstall
Click **…** on the right side of IntelliJ IDEA> Uninstall>Uninstall
Then in the pop-up User Account Control, do you want to allow this app from unknown publishers to make changes to your device? Click Yes .
- Uninstall IntelliJ IDEA
If you want to delete cache and local history as well as settings and installed plug-ins, just check ① and ②. I don't tick here
Just click Uninstall directly to uninstall.
uninstalling
uninstall complete
After the uninstallation is complete, click Close to close the uninstallation window.
After IntelliJ IDEA is uninstalled, IntelliJ IDEA cannot be found in the installed applications.
2.4.3 Delete the specified directory
C:\Users\liuguanglei\AppData\Roaming\JetBrains\IntelliJIdea2023.1
C:\Users\liuguanglei\AppData\Local\JetBrains\IntelliJIdea2023.1
-
liuguanglei is the username. The username of each computer may be different.
-
IntelliJIdea2023.1 is the version number of IntelliJ IDEA
If you check Delete settings and installed plug-ins when uninstalling the IntelliJ IDEA program
Then the C:\Users\liuguanglei\AppData\Roaming\JetBrains\IntelliJIdea2023.1 directory will also be deleted together.
By default, the AppData directory in the C:\Users\liuguanglei path is hidden.
You need to select View > Show in File Explorer and select hidden items
to see the AppData folder
- Delete the IntelliJIdea2023.1 folder under the C:\Users\liuguanglei\AppData\Roaming\JetBrains\ path
successfully deleted
- Delete the IntelliJIdea2023.1 folder in the C:\Users\liuguanglei\AppData\Local\JetBrains directory
successfully deleted
- Empty Recycle Bin
The two folders just deleted are both in the Recycle Bin, so you need to empty the Recycle Bin to delete them completely.
Left click to select Recycle Bin, right click > Empty Recycle Bin
Confirm to delete these two
Trash has been emptied
2.4.4 Deleting Registry Keys
Left-click the Start menu, then search for regedit in the search box, select Registry Editor and click Open
In the **User Account Control that pops up, do you want to allow this app to make changes to your device? **Click Yes
Open the Registry Editor
Then select the computer and press Ctrl+F to find JavaSoft
searching
Computer\HKEY_CURRENT_USER\Software\JavaSoft will be searched by default.
Right click to delete the registry key
When deleting, you also need to confirm to permanently delete this item and all sub-items.
JavaSoft registry key deleted successfully
Finally, click the x in the upper right corner to close the Registry Editor
3. IntelliJ IDEA 2023.1 settings for Windows
3.1 IntelliJ IDEA setup instructions
Before using IntelliJ IDEA to develop a project, you need to make some settings. After completing these settings, the project development will be smoother.
IntelliJ IDEA related settings are all done in the settings window , so you first need to know how to open the settings window
First start IntelliJ IDEA
Left-click IntelliJ IDEA on the taskbar
After opening, you can see the IntelliJ IDEA welcome window
Then click Customize>All settings…
You can open the settings window of IntelliJ IDEA, and complete the settings of IntelliJ IDEA under this window
Since IntelliJ IDEA provides a lot of settings, such as appearance and behavior, shortcut keys, editors, plug-ins, version control, etc., a search function is provided to search for settings. It is recommended that you search for related setting items in the search box when making related settings.
There are a few more things to note:
-
If you want to cancel the modification, click Cancel in the lower right corner, and the settings window will close.
-
After making most of the settings, click Apply in the lower right corner and the settings will take effect immediately.
-
After all settings are completed, click OK in the lower right corner to close the settings window.
3.2 Appearance and behavior settings
3.2.1 Appearance settings
3.2.1.1 Theme settings
IntelliJ IDEA default theme selection Darcula
You can switch to other themes according to your preferences, such as IntelliJ Light
However, it should be noted that if you enable the new UI of IntelliJ IDEA, the Darcula theme will be replaced by the Dark theme.
3.2.1.2 Appearance font settings
The default appearance of IntelliJ IDEA uses the Microsoft YaHei UI font with a font size of 12
If it doesn't feel right, you can customize the font and font size
I changed the appearance font size from the default 12 to 16
After making changes, it is recommended to reopen the settings window.
3.2.2 New UI settings
After IntelliJ IDEA 2022.3, a new UI is provided. For a detailed introduction to the new UI, you can visit the official website of IntelliJ IDEA
However, by default, IntelliJ IDEA has not started the new UI, because it is still in the Beta version, so it is not a stable version
If you want to try the new UI, then check Enable new UI and check the need to restart IntelliJ IDEA
IntelliJ IDEA welcome interface after enabling the new UI
Although the UI has changed, the menu name has not changed, so you can still click Customize>All settings…
Enter the settings window
Compared with the previous UI, the new UI will be simpler, more beautiful, and more efficient to operate. In the future, IntelliJ IDEA will also enable the new UI by default, so we will use the new UI throughout the process from now on.
3.2.3 System settings
3.2.3.1 Reopen project settings on startup
By default, IntelliJ IDEA reopens the project when it starts , that is, it directly opens the recently closed project after starting IntelliJ IDEA.
Usually, when a company does Java development, multiple projects may be developed at the same time , so it is recommended to uncheck Reopen projects on startup.
In this way, if there are multiple projects after starting IntelliJ IDEA, you can select the specified project and then open IntelliJ IDEA
3.2.3.2 IntelliJ IDEA update settings
IntelliJ IDEA checks for updates to IntelliJ IDEA and related plug-ins by default
If you do not want to update IntelliJ IDEA or are currently using a stable version , it is recommended to uncheck Check IDE update for Stable Relases and just keep checking for plug-in updates.
3.3 Editor settings
3.3.1 Editor general settings
IntelliJ IDEA editor is not enabled by default to use Ctrl+mouse wheel to adjust font size
It is recommended to enable the use of Ctrl+mouse wheel to adjust the font size, so that when writing code, you can hold down the Ctrl key and scroll the mouse to change the font size at any time. However, this change only takes effect temporarily for the content currently being edited, and the modification will become invalid after restarting IntelliJ IDEA .
3.3.3.1 Automatically import settings
IntelliJ IDEA automatic import settings are not enabled by default to dynamically add explicit import statements and dynamically optimize import statements.
When writing a Java program, by default, if you are using a Java class other than the java.lang package, you need to manually import the package (that is, write an import statement)
In order to develop more efficiently, it is usually recommended to enable dynamic addition of explicit import statements and dynamic optimization of import statements .
However, if there are classes with the same name in different packages (for example, Date is in java.sql and java.util), then you need to manually select the specified package.
3.3.3.2 Appearance settings
By default, IntelliJ IDEA does not enable the separator between display methods
Because we will write many methods in the same class later when writing Java code, in order to make it easier to read the code (to distinguish the method where the code is located), it is recommended to enable the display of separators between methods, that is, between multiple methods add a horizontal line
3.3.3.3 Code completion
Code completion will be performed when using the IntelliJ IDEA editor to write code. For example, if you enter Sy, System will be completed. However, if you enter sy, it will not be completed as System because by default code completion is case-sensitive.
In daily development, it is recommended that code completion is not case-sensitive . Uncheck Match case so that the code can be completed without case-sensitivity. For example, entering sy will complete System
3.3.3.4 Console settings
The default console encoding is the system default encoding GBK
Force the console encoding to be changed from the default GBK to UTF-8
The default console buffer size is 1024KB
It is recommended to change the buffer size of the console to 10240KB so that you can see more console output during later development projects.
3.3.3.5 Editor tab settings
By default, the editor displays tabs in one line . If there are many open files, some file tabs will be hidden.
It is recommended to display tabs on multiple lines so that all tabs can be seen in the editor
3.3.2 Editor font settings
The default font of the IntelliJ IDEA editor is JetBrains Mono, and the font size is 13
The smaller the font size, the more code you can see in the editor, but it takes more effort on your eyes.
Therefore, I changed the font size from the default 13 to 18. After the modification is completed, you can preview the effect on the right
3.3.3 Editor color scheme
IntelliJ IDEA's default font color for single-line comments and multi-line comments is gray, and its color value is hexadecimal 7A7E85
You can view it by selecting Line comment and Block comment of Comments in Editor>Color Scheme>Language Defaults.
Line comment
Block comment
However, the document comment color in IntelliJ IDEA 2023.1 is green , and the color value of the multi-line comment text content is hexadecimal 5F826B
It is recommended to change the color value of the comment content of single-line comments and multi-line comments to the same color as the content of multi-line comments, which is 5F826B in hexadecimal . Of course, you can also choose the color you like.
Change the font color of single-line comments to green
Change the font color of multi-line comments to green
When you write code later, you will see that the color of the contents of the three types of comments (single-line comments, multi-line comments, and document comments) in the program are all green.
3.3.4 File and code template settings
3.3.4.1 File header settings
By default, the file header configuration content of files and code templates is empty.
We can add the following document comment content
/**
* ${description}
* @author tony [email protected]
* @version ${DATE} ${TIME}
* @since Java17
*/
-
${description} is used to describe the role of the class
-
@author The author's email is used to describe the author and email of the class
-
@version ${DATE} ${TIME} uses the current date and time as the version number to describe the version of the class
-
@since Java17 project uses Java17 JDK used to describe project dependencies
This documentation comment will be used later when creating Class, Interface, Enum, and Record.
Because file headers are used in Class, Interface, Enum, and Record file templates
For example, my first Java program used documentation comments for class headers
3.3.5 Editor file encoding settings
Default editor file encoding settings
The default encoding of the project encoding and property files must be adjusted to UTF-8, and check the box to automatically convert to Ascii but display native content.
3.4 Build, Execution, and Deployment Settings
3.4.1 Compiler settings
When using IntelliJ IDEA to develop Java projects, it is recommended to enable automatic project building and parallel compilation of independent modules.
Automatically building projects only works when not running/debugging. Parallel compilation of independent modules requires larger heap memory, so the default 700M is adjusted to 4096M, which will be used if multi -module projects are developed in the future.
3.5 Advanced settings
3.5.1 User interface settings
When we write code, we often use shift to switch between Chinese and English, and this is easy to trigger double-click shift to open the search box of IntelliJ IDEA. The search box can search for any content, so it is recommended to double-click shift to open any search and disable it .
So what do you do if you want to search for any content?
You can use Ctrl+N to open IntelliJ IDEA's search box search class. Click All to search for any content in the search box.
You can use Ctrl+Shift+N to open the search box of IntelliJ IDEA to search for files. Click All to search for any content in the search box.
After all settings are completed, click OK to close the window.
Click the x in the IntelliJ IDEA welcome window to close IntelliJ IDEA
3.6 IntelliJ IDEA JVM settings
IntelliJ IDEA runs on the JVM. We can modify the options of the JVM to adjust the performance of IntelliJ IDEA. The IntelliJ IDEA help document also provides detailed configuration methods https://www.jetbrains.com/help/idea/tuning-the- ide.html#configure-jvm-options
First enter the bin directory C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.3\bin of the IntelliJ IDEA installation directory
Then modify the idea64.exe.vmoptions file, which can be opened using a text editor (such as Visual Studio Code)
It is strongly recommended to back up before modifying . The purpose is to prevent IntelliJ IDEA from being unable to start due to modifying the file and restore it to the backup.
-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=512m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:+IgnoreUnrecognizedVMOptions
-XX:CompileCommand=exclude,com/intellij/openapi/vfs/impl/FilePartNodeRoot,trieDescend
-ea
-Dsun.io.useCanonCaches=false
-Dsun.java2d.metal=true
-Djbr.catch.SIGABRT=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
If your computer has more than 32G of memory, you can refer to the following configuration
Modify the following parameters
-
-Xms1024m
-
-Xmx3000m
-
-XX:ReservedCodeCacheSize=2048m
-
-XX:SoftRefLRUPolicyMSPerMB=200
-
-XX:CICompilerCount=8
-Xms1024m
-Xmx3000m
-XX:ReservedCodeCacheSize=2048m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=200
-XX:CICompilerCount=8
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:+IgnoreUnrecognizedVMOptions
-XX:CompileCommand=exclude,com/intellij/openapi/vfs/impl/FilePartNodeRoot,trieDescend
-ea
-Dsun.io.useCanonCaches=false
-Dsun.java2d.metal=true
-Djbr.catch.SIGABRT=true
-Djdk.http.auth.tunneling.disabledSchemes=“”
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
After making the changes, remember to restart IntelliJ IDEA and test whether it can be opened normally.
Later, when developing large-scale projects, you will find that after adjusting the JVM Options, it becomes smoother and silkier than the default configuration.
4. Develop Java projects with IntelliJ IDEA 2023.1 for Windows
4.1 Process of developing Java projects with IntelliJ IDEA
-
Create a new project (Project)
-
Create a new module (Module)
-
Create a new package
-
Create a new class
-
Run and debug Java programs
About the relationship between projects, modules, packages and classes
-
A project (Project) can contain multiple modules (Module)
-
A module (Module) can contain multiple packages (Package)
-
A package (Package) can contain multiple classes (Class)
This is similar to a school having multiple grades, a grade having multiple classes, and a class having multiple students.
4.2 IntelliJ IDEA new project
- Start IntelliJ IDEA
Double-click the IntelliJ IDEA shortcut on the desktop to start IntelliJ IDEA
IntelliJ IDEA started successfully
- New Project
Click Projects->New Project to create a project
-
New Project Create a new project
-
Open Open an existing project
-
Get from VCS Get the project from the version control system
- Set the project type, project name, and project path in turn. Set the project type to Empty Project. Set the project name to java. Set the project path to D:\projects\java\ittimeline. Note that the project path does not contain Chinese and spaces
After the settings are completed, click Create to create the project.
Project created successfully
- set items
First click on IDE and Project Settings in the upper right corner, then click on Project Structure to open the project settings. The shortcut key is Ctrl+Alt+Shift+S
The project structure is divided into project settings (Project Settings) and platform settings (Platform Settings)
The project name, SDK (Software Development Kit), language level and compiler output directory can be set in the Project of Project Settings
-
The project name is java
-
Project SDK no selection
-
Language level is 20
-
The compilation output directory is D:\projects\java\ittimeline\java\out, which is used to store bytecode files.
Here we set the project SDK to Java8, and the language level is also set to 8. Normally, the SDK and language level versions are consistent.
It should be noted that the module will use the default settings of the project, that is, the SDK after the new module is also Java8, and the language level is 8
When creating a Project, IntelliJ IDEA will also automatically create a Module with the same name.
In the SDKs of Platform Settings, IntelliJ IDEA automatically reads the locally installed Java17 and Java8, but the prerequisite is that Java17 and Java8 have been installed in the local environment
If you want to integrate other versions of SDK, just click the plus sign (+)->Add JDK
Then select the installation directory of other versions of JDK and click OK
Finally click Apply
In this way, three different versions of JDK of Java8, Java11 and Java17 are integrated in IntelliJ IDEA
After the project setting is complete, click OK to close the project setting window
4.3 IntelliJ IDEA new module
- New Module
Select the java project, then right-click New Module
- Setup module
Set module name, module path, language, build system, JDK new module default settings
Since the SDK was previously set to Java8 in the project settings, the JDK default is Project SDK1.8 when creating a new module.
The module settings are as follows
-
Module name: java-core
-
Module path: D:\projects\java\ittimeline\java
-
Language:Java
-
Build system: IntelliJ
-
JDK:Java17
-
Uncheck Add sample code
After the module is set up, click Create to create the module.
After creating the module, IntelliJ IDEA will create an index for Java17, so that the search efficiency can be improved when searching the API provided by Java17 in the future. We need to wait for the index to be created before performing other operations
The java-core module was created successfully
- Module settings
First click on IDE and Project Settings in the upper right corner, then click on Project Structure to open the project settings. The shortcut key is Ctrl+Alt+Shift+S
In the Modules of Project Settings, you can see that the Language Level of javac-core inherits the Language Level of Project, which is Java8.
Since the new features of Java17 will be used later, it will be changed to Java17
After the module settings are completed, click OK to close the project settings window.
4.4 IntelliJ IDEA new package
- New Pacakge
Select the src directory of the java-core module and right-click New Package
- Set the package name, enter net.ittimeline.java.core.foundational.object and press Enter
Why should it be set to net.ittimeline.java.core.foundational.object? In fact, it has a special meaning
The Java development specification stipulates that the package name must be a lowercase English word, and multiple words are separated by .
-
net.ittimeline means that the ittimeline.net domain name is reversed. If you develop a Taobao project, then the package name is com.taobao
-
java.core represents the java language, that is, stores Java language-related codes, such as basic syntax, object-oriented, collection, concurrency, and network-related APIs
-
foundational means that the basic grammar of java is the content that stores the basic grammar of java, such as variables, data types, operators, program flow control, arrays
-
object indicates that the object is to store the first Java program
Package created successfully
What exactly is a bag?
We can open the package in file explorer
Then you will see its essence, which is actually a folder that stores Java source files with different functions.
4.5 IntelliJ IDEA new class
- New Class
Select the net.ittimeline.java.core.foundational.object package and right-click New Java Class
- To set the class name, enter HelloWorld and press Enter. It should be noted that you select Class. As for Interface, Record, Enum, and Annotation, you will learn about it later.
Then enter the description and click OK after entering to create the HelloWorld class.
HelloWorld class created successfully
And IntelliJ IDEA also helps us write the following code
package net.ittimeline.java.core.foundational.object;
/**
* 我的第一个Java程序
*
* @author tony [email protected]
* @version 2023/7/4 13:32
* @since Java17
*/
public class HelloWorld {
}
-
package net.ittimeline.java.core.foundational.object; defines the package (that is, the folder) where the HelloWorld class is located
-
public class HelloWorld {} is to define the public class HelloWorld
The content of the documentation comment was previously configured in the file header of the file and code template.
-
Writing HelloWorld
package net.ittimeline.java.core.foundational.object;
/**
- My first Java program
- @author tony [email protected]
- @version 2023/7/4 13:32
- @since Java17
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Windows11 & Java17 & IntelliJ IDEA 2023”);
}
}
However, writing Java code in IntelliJ IDEA is more efficient than Notepad.
-
Enter psvm or main and press Enter to generate the main method.
-
Enter soout to generate a print statement
This is the Live Templates function provided by IntelliJ IDEA. You can view it in the Live Templates of the IntelliJ IDEA settings window. First click IDE and Project Settings in the upper right corner, and then click Settings. The shortcut key is Ctrl+Alt+S
You can open the settings window
Then search for Live Templates in the settings window and select Live Templates for Java
When you see Java's psvm Live Template, you will know why entering psvm can generate the main method.
When you see Java's sout Live Template, you will know why typing soout can generate the print statement System.out.println();
As for other Live Templates, we will use them later when learning other content.
4.6 IntelliJ IDEA runs Java programs
IntelliJ IDEA has four ways to run Java programs, the most commonly used method is 4, because the position is always fixed.
Method 1: Right-click in the editing area and select Run. The shortcut key is Ctrl+Shift+F10.
Method 2: Click the Rerun button in the run window to run
Method 3: Click the triangle button on the left of the main method
Then select Run
Method 4: Click the triangle button of the Toolbar to run
Regardless of the running method, you will see the same running result in the Run window, that is, print out Windows11 & Java17 & IntelliJ IDEA 2023 and wrap
program running result
4.7 IntelliJ IDEA project structure
This is our java project structure so far
-
The java project name stores project codes, documents, etc.
-
The .idea folder stores project configurations, such as project version control configuration, project module configuration, etc. This directory is created by IntelliJ IDEA. We generally do not modify the contents of files in this directory.
-
The java-core module name stores content related to the Java language, such as Java's basic syntax, object-oriented, advanced API, etc.
-
src stores Java source files , resource files (html, css, js), and configuration files (application.yml)
-
The package name net.ittimeline.java.core stores source files related to the Java language.
-
.gitignore git ignores files. If some files and directories do not want to be submitted to the Git repository, you can configure it in this file.
-
-
java-core.iml module configuration file, each module will have a module configuration file, generally we will not modify it, this file is created by IntelliJ IDEA
-
-
out store the bytecode file and configuration file output by project compilation
-
java.iml module configuration file, each module will have a module configuration file, generally we will not modify it, this file is created by IntelliJ IDEA
-
-
External Libraries stores the class libraries that the project depends on, currently only depends on Java17