1. IntelliJ IDEAIntroduction
IntelliJ IDEA is 一款由JetBrainsDevelopment 集成Developmentenvironment (IDE) , 主要用于Java, Kotlin, Scalaetc.programminglanguage Development. 它以其强 big 智能code补全, codeanalysis, refactorfunctions and 丰富 插件ecosystem而闻名, is 目 before 最受欢迎 Java IDE之一.
IntelliJ IDEAproviding了两个version:
- community版 (Community Edition) : 免费open-source, 主要supportJava, Kotlin, Scalaetc.language BasicsDevelopment
- 终极版 (Ultimate Edition) : 商业版, package含community版 所 has functions, 并增加了 for 更 many language and framework support, such asJavaScript, TypeScript, Python, Ruby, PHP, Goetc., 以及datalibrarytool, applicationserver集成etc.advancedfunctions
for 于 big many 数JavaDevelopment者来说, community版已经足够满足日常Developmentrequirements. such as果你需要Developmentotherlanguage or usingadvancedfunctions, 可以考虑购买终极版 or 申请教育License (免费) .
2. system要求
in installationIntelliJ IDEA之 before , 你需要确保你 计算机满足以 under system要求:
2.1 硬件要求
- CPU: 至 few 双核processing器, 推荐四核 or 更 high
- memory: 至 few 4GB RAM, 推荐8GB or 更 high
- 硬盘: 至 few 2GB可用空间, 推荐SSD
- 分辨率: 至 few 1024x768, 推荐1920x1080 or 更 high
2.2 软件要求
- operationsystem: Windows 10/11 (64-bit), macOS 10.15 or 更 high , Linux发行版 (64-bit)
- JDK: Java Development Kit, 推荐JDK 11 or 更 high version
提示
IntelliJ IDEA自带了JRE (Java Runtime Environment) , 但建议你 in systemininstallation完整 JDK, 以便forJavaDevelopment.
3. Windowssysteminstallation
in Windowssystem on installationIntelliJ IDEA非常 simple , 按照以 under 步骤operation:
3.1 under 载installationpackage
- 访问JetBrains官方网站: https://www.jetbrains.com/idea/download/
- in "IntelliJ IDEA"页面, 选择"Windows"选项卡
- 根据你 requirements, 点击"Download"按钮 under 载community版 or 终极版installationpackage
3.2 runinstallation程序
- 找 to under 载 installationpackage (通常 in " under 载"file夹in) , 双击run
- in installation向导in, 点击"Next"按钮
- 选择installationTable of Contents, 建议using默认Table of Contents, 点击"Next"
- 选择installation选项:
- 勾选"Create Desktop Shortcut" (creation桌面 fast 捷方式)
- 勾选"Add "Open Folder as Project" (添加"以project方式打开file夹")
- 勾选"Add Launcher Directory to PATH" (将启动器Table of Contents添加 to PATH)
- 根据你 systemarchitecture选择"64-bit launcher" or "32-bit launcher"
- 点击"Next"
- 选择开始菜单file夹, 点击"Install"
- etc.待installationcompletion, 点击"Finish"
3.3 首次启动
- 双击桌面 fast 捷方式启动IntelliJ IDEA
- in 欢迎界面, 选择"Do not import settings", 点击"OK"
- 选择UI主题 (Darcula or Light) , 点击"Next: Featured plugins"
- 选择要installation 插件, or 直接点击"Start using IntelliJ IDEA"
4. macOSsysteminstallation
in macOSsystem on installationIntelliJ IDEA has 两种方式: using.dmginstallationpackage or usingHomebrew.
4.1 using.dmginstallationpackage
- 访问JetBrains官方网站: https://www.jetbrains.com/idea/download/
- in "IntelliJ IDEA"页面, 选择"macOS"选项卡
- 根据你 requirements, 点击"Download"按钮 under 载community版 or 终极版installationpackage
- 找 to under 载 .dmgfile, 双击打开
- 将IntelliJ IDEAgraph标拖动 to "Applications"file夹in
- in "Applications"file夹in找 to IntelliJ IDEA, 双击打开
- 按照首次启动向导completion设置
4.2 usingHomebrew
such as果你已经installation了Homebrew, 可以using以 under commandsinstallationIntelliJ IDEA:
brew install --cask intellij-idea-ce # installationcommunity版 brew install --cask intellij-idea # installation终极版
提示
usingHomebrewinstallation application会自动添加 to Launchpadin, 你可以 from Launchpad or Applicationsfile夹in启动IntelliJ IDEA.
5. Linuxsysteminstallation
in Linuxsystem on installationIntelliJ IDEA has many 种方式, includingusing.tar.gz压缩package, Snappackage or Flatpakpackage.
5.1 using.tar.gz压缩package
- 访问JetBrains官方网站: https://www.jetbrains.com/idea/download/
- in "IntelliJ IDEA"页面, 选择"Linux"选项卡
- 根据你 requirements, 点击"Download"按钮 under 载community版 or 终极版 .tar.gzfile
- 打开终端, 导航 to under 载Table of Contents
- 解压.tar.gzfile:
tar -xzf ideaIC-*.tar.gz # community版 # or tar -xzf ideaIU-*.tar.gz # 终极版
- 将解压 after file夹move to 合适 位置, such as/optTable of Contents:
sudo mv idea-* /opt/idea
- 进入IntelliJ IDEATable of Contents, runinstallation脚本:
cd /opt/idea/bin ./idea.sh
- 按照首次启动向导completion设置
5.2 usingSnappackage
such as果你using is supportSnap Linux发行版 (such asUbuntu) , 可以using以 under commandsinstallation:
sudo snap install intellij-idea-community --classic # community版 sudo snap install intellij-idea-ultimate --classic # 终极版
5.3 creation桌面 fast 捷方式
首次runIntelliJ IDEA after , 你可以creation桌面 fast 捷方式:
- in IntelliJ IDEAin, 点击"Tools"菜单
- 选择"Create Desktop Entry"
- 勾选"Create the entry for all users" (可选)
- 点击"OK"
6. configurationJDK
IntelliJ IDEA需要JDK来编译 and runJava程序. such as果你 systemin已经installation了JDK, IntelliJ IDEA会automatically detect to 它. such as果没 has , 你可以按照以 under 步骤configurationJDK:
6.1 under 载并installationJDK
- 访问Oracle官网 or OpenJDK官网 under 载JDK:
- Oracle JDK: https://www.oracle.com/java/technologies/downloads/
- OpenJDK: https://adoptium.net/
- 按照installation向导completionJDKinstallation
6.2 in IntelliJ IDEAinconfigurationJDK
- 启动IntelliJ IDEA
- 点击"File"菜单, 选择"Project Structure"
- in "Project Structure" for 话框in, 选择"Project"选项卡
- in "Project SDK" under 拉菜单in, 选择"Add SDK" → "JDK"
- 浏览 to JDKinstallationTable of Contents, 点击"OK"
- 点击"Apply" and "OK"保存设置
提示
你可以 in IntelliJ IDEAinconfiguration many 个JDK, 以便 in 不同projectinusing不同version JDK.
7. 实践case: creation你 第一个IntelliJ IDEAproject
现 in , 让我们through一个 simple 实践case来Learningsuch as何usingIntelliJ IDEAcreation and runJavaproject:
- 启动IntelliJ IDEA
- in 欢迎界面, 点击"New Project"
- 选择"Java", 确保"Project SDK"已正确configuration
- 点击"Next"
- 取消勾选"Create Git repository" (我们将 in after 续tutorialinLearningGit)
- 点击"Next"
- 输入project名称, such as"HelloWorld"
- 选择project位置
- 点击"Finish"
- in projectstructurein, right 键点击"src"Table of Contents, 选择"New" → "Package"
- 输入package名, such as"com.example"
- right 键点击刚creation package, 选择"New" → "Java Class"
- 输入class名, such as"HelloWorld"
- in HelloWorld.javafilein, 输入以 under code:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, IntelliJ IDEA!"); } } - right 键点击HelloWorld.javafile, 选择"Run 'HelloWorld.main()'"
- in 底部 "Run"窗口in, 你将看 to 输出:
Hello, IntelliJ IDEA!
实践练习
请按照以 under 步骤completion练习:
- 根据你 operationsystem, under 载并installation合适version IntelliJ IDEA
- 启动IntelliJ IDEA, completion首次configuration
- creation一个名 for "Calculator" Javaproject
- creation一个名 for "Calculator" Javaclass, implementation simple 加减乘除functions
- in mainmethodintestCalculatorclass functions
- runproject, 查看输出结果