Intellij Idea 简明教程
Intellij Idea - Migrating from Eclipse
Eclipse 是另一种流行的 Java IDE。如果您是 Eclipse 的现用用户,并想从其迁移到 IntelliJ,那么这是一个很好的起点。
Eclipse is yet another popular Java IDE. If you are a current user of Eclipse and want to migrate from it to IntelliJ, then this is a good starting point.
本章讨论了如何在 IntelliJ 中导入 Eclipse 项目、它的 Eclipse 等价术语、常用快捷方式和常见问题。
This chapter discusses how to import Eclipse projects in IntelliJ, its terminologies equivalent to Eclipse, popular shortcuts and frequently asked questions.
Import existing project
在本节中,我们将讨论如何导入现有项目。请按以下步骤导入项目:
In this section, we will discuss how to import an existing project. Follow these steps to import the project −
-
Navigate to File → New → Project from Existing Sources.
-
Select your NetBeans project directory.
-
When the Import Project wizard opens, select the Create project from existing sources option.
-
Follow the on-screen instructions to continue.
IntelliJ vsEclipse terminology
下表比较了 IntelliJ 和 NetBeans 术语 -
The following table compares IntelliJ and NetBeans terminologies −
IntelliJ |
Eclipse |
Project |
Workspace |
Module |
Project |
Facet |
Facet |
Library |
Library |
SDK |
JRE |
Path variable |
Classpath variable |
Popular shortcuts
IntelliJ 是一个以键盘为中心的 IDE。它为大多数操作提供了快捷键。下表列出了一些常用快捷键 -
IntelliJ is a keyboard-centric IDE. It provides shortcuts for most of the actions. The following table lists a few popular shortcuts −
Action |
Shortcut |
Run java program |
ctrl+shift+F10 |
Organize imports |
ctrl+alt+o |
System.out.println() |
Type sout and Press ctrj+j |
Delete current line |
ctrl + y |
Search |
ctrl + shift + f |
Generate getter and setter |
alt + insert |
Format code |
ctrl + alt + l |
Comment out code |
ctrl + / |
Go to line |
ctrl + g |
Go to declaration |
ctrl + b |
Rename |
shift+F6 |
Move lines |
ctrl + shift + up/down |
Debugger shortcuts
下表列出了一些常用的调试快捷键 -
The following table lists down commonly used debugger shortcuts −
Debug action |
Shortcut |
Debug a program |
Shift + F9 |
Choose configuration and debug |
Shift+Alt+F9 |
Step over |
F8 |
Step into |
F7 |
Smart step into |
Shift + F7 |
Step out |
Shift + F8 |
Force step over |
Shift+Alt+F8 |
Force step into |
Shift+Alt+F7 |
Resume program |
F9 |
Evaluate expression |
Alt+F8 |
Toggle breakpoints |
Ctrl+F8 |
View breakpoints |
Ctrl+Shift+F8 |
FAQsand Tips
在此部分中,我们会看到一些常见问题和提示。常见问题及提示如下 -
In this section, we will see a few Frequently Answered Questions and tips. The FAQs and tips are as follows −
Use Eclipse Compiler
Eclipse 使用它自己的编译器,而 IntelliJ IDEA 使用与项目 JDK 捆绑在一起的 javac 编译器。如果你想使用 Eclipse 编译器 -
While Eclipse uses its own compiler, IntelliJ IDEA uses the javac compiler bundled with the project JDK. If you want to use the Eclipse compiler −
-
Navigate to File → Settings → Build, Execution, Deployment → Compiler → Java Compiler.
-
Select the required compiler from User compiler dropdown.

Eclipse Keymap
对于不想学习新快捷键的 Eclipse 用户,IntelliJ IDEA 提供了 Eclipse 快捷键映射,它非常类似其快捷键 -
For Eclipse users who prefer not to learn new shortcuts, IntelliJ IDEA provides the Eclipse keymap that closely mimics its shortcuts −
-
Navigate to File → Settings → Keymap option.
-
Select Eclipse from Keymap dropdown.

Code formatting
若要导入你的 Eclipse 格式化程序设置 -
To import your Eclipse formatter settings −
-
Navigate to File → Settings → Editor → Code Style → Java.
-
Select the Eclipse XML profile.

Working with Build Tools
与 Eclipse 类似,IntelliJ 并不为编辑 Maven/Gradle 配置文件提供可视化形式。
Like Eclipse, IntelliJ does not provide visual forms for editing Maven/Gradle configuration files.
一旦你导入/创建了你的 Maven/Gradle 项目,你就可以直接在文本编辑器中编辑其 pom.xml/build.gradle 文件。
Once you have imported/created your Maven/Gradle project, you are free to edit its pom.xml/build.gradle files directly in the text editor.