morris950318
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Java 環境建置教學(Windows & macOS) 這篇教學將會帶你簡單認識什麼是程式語言、並教你如何在你的電腦上建置出能夠寫 Java 程式的環境!本教學涵蓋 Windows 和 macOS 兩大作業系統,如果喜歡看影片版本,以下是我錄製的教學影片:https://youtu.be/AsXIN-mrigo #### ==如果喜歡看純文字版本,就繼續看下去吧! ( ̄^ ̄)ゞ== >PS: 本人製作教學時也需要上網找影片學,不排斥英文的同學之後也可以參考以下這兩部不錯的教學影片來操作(安裝環節我主要就是看這兩位印度小哥學的): >Windows: https://www.youtube.com/watch?v=VUcI3Y1Nnak >MacOS: https://www.youtube.com/watch?v=hIikXmXQpD4 &nbsp; ## 教學大綱 :::info - 說明什麼是「程式語言」、「IDE」、「Compiler」、「Machine code」 - 安裝 Java (JDK 17,21,23...) - 設置環境變數 - 安裝 VS code 以及 實用插件(extensions) - 寫出第一個Java程式! ::: &nbsp; &nbsp; # 零、先備知識介紹 :::success 為了讓完全沒接觸過程式的同學等一下能知道自己在幹麻,以下會做一點入門知識講解。已經了解的同學可以直接跳到[一、安裝Java](#一、安裝Java(JDK))。 ::: &nbsp; ## 什麼是「程式語言」? **程式語言**就是人類用來和電腦溝通、命令電腦幫我們做事的語言。今天我們要安裝的,就是眾多程式語言中的一種:Java。 然而,如果你有看過任何一種常見程式語言的程式碼,你就會發現他仍然是以**英文**撰寫的。換而言之,只看得懂0和1的電腦,其實是無法直接看懂我們寫的程式碼。 因此,我們寫完<font color="F7A004">程式碼(code)</font>後,還需要請<font color="#fd4340">編譯器(Compiler)</font>幫我們把程式碼翻譯成由0和1組成的<font color="F7A004">機器碼(machine code)</font>,這樣電腦才終於能理解我們想要它做什麼。 >[!Note]補充說明 有些較現代的程式語言(如Python,Javascript)不是透過<font color="#fd4340">編譯器(Compiler)</font>來翻譯,而是使用<font color="#fd4340">直譯器(Interpreter)</font>。<font color="#fd4340">直譯器</font>是逐行翻譯執行,<font color="#fd4340">編譯器</font>則是一次性將整個 code 翻譯後再執行。但反正Java是使用**編譯器**啦~ &nbsp; ## 什麼是「IDE」? IDE 是整合開發環境(Integrated Development Environment)的縮寫,簡單來說,就是一種能讓你寫程式更舒服、更方便的工具。雖然不用 IDE,你一樣可以用記事本寫出功能相同的程式碼,但使用 IDE 可以幫助你更快速地撰寫、除錯、編譯和執行程式,所以幾乎所有人寫 code 都會選擇使用 IDE 或類似工具! 而目前最廣為人知、新手友善的IDE就是由微軟開發的免費軟體 <font color="#449df9">**Visual Studio Code(通常簡稱VS code)**</font>,所以今天我們也會帶大家安裝這個帥氣好用的軟體! >其實VS code本身只是一個文字編輯器(text editor),不能稱作IDE。但是透過其方便的擴充套件安裝功能,使它也能變得像IDE一樣強大。 ==恭喜各位,先備知識已經講解完畢。接下來就讓我們正式進入安裝環節吧!== &nbsp; &nbsp; &nbsp; # 一、安裝Java(JDK) 首先我們要先來安裝JDK,裡面包含了寫Java所需的各種工具,其中當然包含了剛剛提到的<font color="#fd4340">編譯器(Compiler)</font>。以下為安裝步驟: - 上瀏覽器搜尋「oracle java download」或是直接點擊以下連結:https://www.oracle.com/java/technologies/downloads/ - 點擊 **JDK 21** ,選擇你的作業系統(Windows 或 macOS)。 - Window: 選「x64 Installer」進行下載 - macOS: - M系列晶片(近幾年的新筆電 M1,M2,M3,M4...) -> 選「ARM64 DMG Installer」進行下載。 - Intel的晶片(好幾年前的舊筆電) -> 選「x64 DMG Installer」進行下載。 - 等待下載完畢,點開剛剛載好的東西,按照指示完成JDK安裝(一直按下一步讓JDK安裝在預設位置就可以了) >詳細畫面可參考[教學影片](https://youtu.be/AsXIN-mrigo) &nbsp; &nbsp; &nbsp; # 二、設置環境變數 這部分 Windows 和 macOS 做法差異比較大,以下將分開說明 &nbsp; ### Windows --- - 打開「檔案總管」,沿著以下路徑點開:本機 -> 本機磁碟(C:) -> Program Files -> Java-> jdk-21 -> bin - 點選檔案總管上方的路徑欄,複製當前路徑。(應該會是 *C:\Program Files\Java\jdk-21\bin* ,複製好之後就可以關閉檔案總管了) - 在Windows下方工具欄的搜尋框搜尋「編輯系統環境變數(edit the system environment variables)」,並點開。 - 點擊下方「環境變數」按鈕。 - 在「系統變數」中找到變數「PATH」。點選PATH之後,按下「編輯」。 - 按右邊的「新增」,並貼上剛剛複製好的路徑。 - 成功貼上後,就可以一直按「好」完成設定。 &nbsp; ### macOS --- 我大 macOS 非常的聰明,在這部分就算不設置也能跑 Java 了。除非是要做進階的專案之類的?( *我也不是很清楚* ) 才會需要去設置JAVA_HOME。這部分就等各位未來有需求再去設置吧,在此新手教學中就跳過這部分囉! >其實設置的步驟也太複雜,有興趣的可以看看以下這部教學,裡面有教要怎麼設置JAVA_HOME:https://www.youtube.com/watch?v=hIikXmXQpD4 &nbsp; --- 現在你應該已經安裝好Java了,不論是 Windows 還是 macOS 使用者,都可以透過在終端機中輸入「java -\-version」來確認自己是否已經安裝成功。輸入後有顯示你的java版本的話,代表安裝成功。若是沒有,代表可能失敗了或是要重開電腦再試一次) >[!Tip]打開終端機(terminal)的方法 **Windows:** 在下方搜尋欄輸入「cmd」,並點擊「命令提示字元」。 **macOS:** 鍵盤「command + 空白鍵」叫出搜尋欄,輸入「terminal」並按下Enter。 &nbsp; &nbsp; &nbsp; # 三、安裝VScode 恭喜各位!最困難的步驟已經結束了。接下來步驟都很簡單: - 上瀏覽器搜尋「vscode」或是直接點擊以下連結:https://code.visualstudio.com - 按「Download for Windows/macOS」 - 等待下載完畢,點開剛剛載好的東西,按照指示完成VScode安裝(同樣一直按下一步就可以了)。 >[!Caution]安裝好VScode之後,Windows用戶請點開「For Windows User」並依其內容操作。macOS用戶則可以跳過,直接接續下方「打開VScode」步驟。 :::spoiler For Windows User 剛剛我們已經分別安裝好了「JDK」和「VScode」,可是VScode尚未與JDK完成聯繫,所以我們還需要再依照以下步驟下載「Coding Pack for Java」: - 瀏覽器搜尋「vscode doc java getting started」或是點以下連結:https://code.visualstudio.com/docs/java/java-tutorial - 點「Install the Coding Pack for Java - Windows」進行下載 - 點開剛下載好的.exe然後故技重施,一路給他同意下去直到完成安裝!!! - 安裝完畢後,就可以接續下方「打開VScode」步驟了。 ::: &nbsp; - 打開VScode *(也許它已經自動幫你打開了)*。 - 點擊畫面左側欄位的「Extensions(圖示是四個方塊)」。 - 搜尋「Extension Pack for Java」並下載(install)。 - 搜尋「Code Runner」並下載(install)。 (Code Runner非必要,但有了它使我們能夠方便的編譯並執行程式碼) &nbsp; &nbsp; &nbsp; # 四、寫出第一個Java程式! - 在你電腦中任意一處建立一個新的資料夾(推薦在桌面即可),資料夾命名也隨你高興。 - 回到VScode,在上方工具欄點「File」+「Open Folder」,選擇你剛剛新建立資料夾。它如果問你信不信任這個資料夾,你就勾選信任並按確認。 - 按左上角的「New File」![image](https://hackmd.io/_uploads/BJL1cMdQll.png) - 檔名取做「Hello.java」 - **手動輸入** 或是 **複製貼上** 以下程式碼: ```java= public class Hello{ public static void main(String[] args){ System.out.println("Hello WARUDO!"); } } ``` - 點擊右上角的三角形圖示,透過Code Runner編譯並執行剛剛寫好的code (記得先存檔在編譯&執行) - 如果在下方輸出結果看到「Hello WARUDO!」,就代表你成功啦!!! >[!Important]信仰除錯法 上述操作如果失敗、遇到問題,可以先嘗試重開VScode或是重開電腦。重開機的期間記得虔誠拜三拜,保證不保證會有奇效!? &nbsp; &nbsp; &nbsp; ## 結語 :::success 恭喜你,已經正式完成Java的環境建置了! 感謝耐心觀看完本篇教學,趕快開始你的Java之旅吧ψ(`∇´)ψ :::

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully