IntelliJ IDEA入门 and installation

UnderstandIntelliJ IDEA basicconcepts, Learningsuch as何 in 不同operationsystem on installation and configurationIntelliJ IDEA

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

  1. 访问JetBrains官方网站: https://www.jetbrains.com/idea/download/
  2. in "IntelliJ IDEA"页面, 选择"Windows"选项卡
  3. 根据你 requirements, 点击"Download"按钮 under 载community版 or 终极版installationpackage

3.2 runinstallation程序

  1. 找 to under 载 installationpackage (通常 in " under 载"file夹in) , 双击run
  2. in installation向导in, 点击"Next"按钮
  3. 选择installationTable of Contents, 建议using默认Table of Contents, 点击"Next"
  4. 选择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"
  5. 点击"Next"
  6. 选择开始菜单file夹, 点击"Install"
  7. etc.待installationcompletion, 点击"Finish"

3.3 首次启动

  1. 双击桌面 fast 捷方式启动IntelliJ IDEA
  2. in 欢迎界面, 选择"Do not import settings", 点击"OK"
  3. 选择UI主题 (Darcula or Light) , 点击"Next: Featured plugins"
  4. 选择要installation 插件, or 直接点击"Start using IntelliJ IDEA"

4. macOSsysteminstallation

in macOSsystem on installationIntelliJ IDEA has 两种方式: using.dmginstallationpackage or usingHomebrew.

4.1 using.dmginstallationpackage

  1. 访问JetBrains官方网站: https://www.jetbrains.com/idea/download/
  2. in "IntelliJ IDEA"页面, 选择"macOS"选项卡
  3. 根据你 requirements, 点击"Download"按钮 under 载community版 or 终极版installationpackage
  4. 找 to under 载 .dmgfile, 双击打开
  5. 将IntelliJ IDEAgraph标拖动 to "Applications"file夹in
  6. in "Applications"file夹in找 to IntelliJ IDEA, 双击打开
  7. 按照首次启动向导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

  1. 访问JetBrains官方网站: https://www.jetbrains.com/idea/download/
  2. in "IntelliJ IDEA"页面, 选择"Linux"选项卡
  3. 根据你 requirements, 点击"Download"按钮 under 载community版 or 终极版 .tar.gzfile
  4. 打开终端, 导航 to under 载Table of Contents
  5. 解压.tar.gzfile:
    tar -xzf ideaIC-*.tar.gz  # community版
    #  or 
    tar -xzf ideaIU-*.tar.gz  # 终极版
  6. 将解压 after file夹move to 合适 位置, such as/optTable of Contents:
    sudo mv idea-* /opt/idea
  7. 进入IntelliJ IDEATable of Contents, runinstallation脚本:
    cd /opt/idea/bin
    ./idea.sh
  8. 按照首次启动向导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 捷方式:

  1. in IntelliJ IDEAin, 点击"Tools"菜单
  2. 选择"Create Desktop Entry"
  3. 勾选"Create the entry for all users" (可选)
  4. 点击"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

  1. 访问Oracle官网 or OpenJDK官网 under 载JDK:
  2. 按照installation向导completionJDKinstallation

6.2 in IntelliJ IDEAinconfigurationJDK

  1. 启动IntelliJ IDEA
  2. 点击"File"菜单, 选择"Project Structure"
  3. in "Project Structure" for 话框in, 选择"Project"选项卡
  4. in "Project SDK" under 拉菜单in, 选择"Add SDK" → "JDK"
  5. 浏览 to JDKinstallationTable of Contents, 点击"OK"
  6. 点击"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:

  1. 启动IntelliJ IDEA
  2. in 欢迎界面, 点击"New Project"
  3. 选择"Java", 确保"Project SDK"已正确configuration
  4. 点击"Next"
  5. 取消勾选"Create Git repository" (我们将 in after 续tutorialinLearningGit)
  6. 点击"Next"
  7. 输入project名称, such as"HelloWorld"
  8. 选择project位置
  9. 点击"Finish"
  10. in projectstructurein, right 键点击"src"Table of Contents, 选择"New" → "Package"
  11. 输入package名, such as"com.example"
  12. right 键点击刚creation package, 选择"New" → "Java Class"
  13. 输入class名, such as"HelloWorld"
  14. in HelloWorld.javafilein, 输入以 under code:
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello, IntelliJ IDEA!");
        }
    }
  15. right 键点击HelloWorld.javafile, 选择"Run 'HelloWorld.main()'"
  16. in 底部 "Run"窗口in, 你将看 to 输出: Hello, IntelliJ IDEA!

实践练习

请按照以 under 步骤completion练习:

  1. 根据你 operationsystem, under 载并installation合适version IntelliJ IDEA
  2. 启动IntelliJ IDEA, completion首次configuration
  3. creation一个名 for "Calculator" Javaproject
  4. creation一个名 for "Calculator" Javaclass, implementation simple 加减乘除functions
  5. in mainmethodintestCalculatorclass functions
  6. runproject, 查看输出结果