直接開啟命令列教學中建立的 HelloWorld.java,或在 Eclipse 中新建:
New → Classcom.example(建議)HelloWorldpublic static void main(String[] args)package com.example;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Run As → Java Application.java → .class 再執行底部 Console 視圖 顯示:
Hello, World!
Window → Show View → ConsoleWindow → Perspective → Reset Perspective 重置透視圖| 問題 | 解決方案 |
|---|---|
| 提示 "Selection does not contain a main type" | 確認類別有 public static void main(String[] args) |
| 編碼亂碼 | 專案右鍵 → Properties → Resource → Text file encoding → UTF-8 |
| JRE 版本不符 | 專案右鍵 → Build Path → Libraries → 移除舊 JRE → Add Library → JRE System Library |