Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

11/20/2012

Eclipse UTF-8 Encoding Prolems

在使用Eclipse的時候發現,若直接匯入.java檔案,原先的中文註記在匯入後會出現亂碼。上網找了一些資料,發現解決方式不難,只要依照以下步驟就可以解決UTF-8的問題。
首先,開啟Eclipse,選擇上工具列的Windows,然後點選Preferences。


接著會跳出新視窗,點選左方工具列的General -> Workspace。
在Workspace中的Text file encoding使用的是預設的Default(GBK)。


將原先預設的Text file encoding改為其他(Other)。在參考的網頁中,都是將編碼改為UTF-8 -> Apply -> OK,然後重新啟動Eclipse,原有的亂碼就會變成繁體中文,可是我試了之後,並沒有改變,只是原有的亂碼變成另一種字型的亂碼。

我的解決方式是一樣選擇其他,但是自行輸入MS950 -> Apply -> OK,也不需要重新啟動,亂碼就全部變成繁體中文了。我的Other清單中並沒有MS950的選項,自行輸入後,就會加到清單裡面了。


參考網站

UTF-8 設定

Eclipse Community Forums

設定Eclipse UTF-8環境

[問題] 中文utf-8與big5互轉的問題

【Eclipse】MS950轉UTF-8亂碼解決方法 中文亂碼

【Eclipse】中文亂碼解決方法:環境編碼設定 UTF-8


3/30/2011

Run HelloWorld in Eclipse

CREATE JAVA PROJECT

Open workbench




Click on File => New => Java Project


create a project name
  • in JRE part, choose "Use default JRE (currently 'jre 6')"
  • in "project layout" part, "Create separate folders for sources and class files" means to save .java and .class files in different folders.

After clicking Finish icon, you will see the project name on the left of the screen.


CREATE PACKAGE


Click on File => New => Package, or
move your mouse to "src" icon and click right button => New => package


give a name to the package



CREATE JAVA CLASS
  • type "HelloWorld" for the name and do not forget capital "H" and capital "W"
  • choose "public static void main(String[] args), and Eclipse will help that for us



type "System.out.println("HelloWorld");"


click Run as => Java application

click OK


and you will see HelloWorld showed on the button of the screen


IMPORT FILES


General => File System



choose only .java files


FIX PROBLEMS