Eclipse (简体中文) - ArchWiki

# Eclipse (简体中文)

本页面或部分需要翻译，部分内容可能已经与英文文章脱节。如果您希望贡献翻译，请访问简体中文翻译组。

附注: 文档后半部分还没有翻译

Eclipse 是一个开源的社区项目，它致力于提供一个通用的开发平台。Eclipse 项目最广为人知的是它的跨平台集成开发环境(IDE)。Arch Linux 软件包 (以及本文) 只针对于此 IDE。

Eclipse IDE 主要是用 Java 书写，但是可以用来用数种语言开发应用程序，包括 Java, C/C++, PHP 和 Perl。此 IDE 也可以提供 subversion 支持(见下文) 以及任务管理 (通过内建的 TODO 列表或者通过 eclipse-mylyn 软件包)。

## 安装

安装位于官方软件仓库的软件包eclipse。

这个基础包内建了 Java 开发支持。

## 插件

有两种方法安装 Eclipse 插件：

- 使用 pacman 来安装 Arch 软件仓库中的插件包 (参见 Eclipse plugin package guidelines 获取更多信息)；
- 使用 Eclipse 中的插件管理器来从自身的仓库中下载和安装插件；这种方法需要你在插件的网站上找到需要的仓库，然后在 Help -> Install New Software...，在 Work with 字段输入仓库，从下面列表中选择要安装的插件，然后按照指示操作。

警告:

- 如果你用 Eclipse 中的插件管理器安装插件，建议使用 root 账户启动 Eclipse。这样插件会安装到`/usr/share/eclipse/plugins/`；如果用普通账户安装，会安装到 `~/.eclipse/` 中的与版本号相关的文件夹中，因此升级 Eclipse 之后就找不到这些插件了。
- 不要用 root 账户使用 Eclipse 来进行日常工作。

### C/C++ 支持

#### Eclipse CDT

- 项目主页: http://www.eclipse.org/cdt/
- [extra] 软件包: eclipse-cdt

### Perl support

#### EPIC

- 项目主页: http://www.epic-ide.org/
- AUR 软件包: eclipse-epic

### PHP support

#### Eclipse PDT

- 项目主页: http://www.eclipse.org/pdt/
- Instructions for the Eclipse plugin version: http://wiki.eclipse.org/PDT/Installation
- AUR 软件包: eclipse-pdt

#### PHPEclipse

- 项目主页: http://www.phpeclipse.com/
- AUR软件包: eclipse-phpeclipse

#### Aptana PHP

见下面的 #Aptana Studio。

### Python support

#### PyDev

- 项目主页: http://pydev.org/
- AUR 软件包: eclipse-pydev

### Web development (HTML, CSS, JavaScript...)

#### Aptana Studio

- 项目主页: http://www.aptana.org/
- 对于 Eclipse 插件版，使用 Eclipse 的插件管理器
- 对于独立版，在 AUR 中有一个软件包: aptana-studio

### Subversion 支持

#### Subclipse

- 项目主页: http://subclipse.tigris.org/
- AUR 软件包: eclipse-subclipse
- How to use Subversion with Eclipse

#### Eclipse Subversive

- 项目主页: http://www.eclipse.org/subversive/
- AUR 软件包: eclipse-subversive

### Git support

#### EGit

- 项目主页: http://www.eclipse.org/egit
- Eclipse 更新链接: http://download.eclipse.org/egit/updates
- AUR 软件包: eclipse-egit

### LaTeX support

#### TeXlipse

- 项目主页: http://texlipse.sourceforge.net/
- Eclipse 更新链接: http://texlipse.sourceforge.net

## 更新

- Eclipse and the plugins installed with pacman are obviously updated with pacman itself.
- For plugins installed with Eclipse's plugin manager, run Eclipse and select Help -> Check for Updates (if you have installed them as root as advised in the section above, you have to run Eclipse as root).

For plugins to be updated, you should check to have their update repositories enabled in Window -> Preferences -> Install/Update -> Available Software Sites: you can find each plugin's repository(es) on the respective project website. To add, edit, remove... repositories just use the buttons on the right of the Available Software Sites panel. For Eclipse 3.7 (Indigo), check you have enabled this repository:

    http://download.eclipse.org/releases/indigo

To receive update notifications, go to Window -> Preferences -> Install/Update -> Automatic Updates. If you want to receive notifications for plugins installed as root, you should run Eclipse as root, go to Window -> Preferences -> Install/Update -> Available Software Sites, select the repositories related to the installed plugins and Export them; then run Eclipse as normal user and Import them in the same panel.

## 启用 javadoc 集成

Want to see API entries when hovering the mouse pointer over standard Java methods?

### 在线版本

If you have constant internet access on your machine, you can use the on-line documentation provided by sun. Just follow these instructions:

1. Go to Window/Preferences, then go to Java/Installed JREs.
2. There should be one named "java" with the type "Standard VM". Select this and click Edit.
3. Select the `/opt/java/jre/lib/rt.jar` item under "JRE system libraries:", then click "Javadoc Location...".
4. Enter "http://java.sun.com/javase/6/docs/api/" in the "Javadoc location path:" text field.
5. Done!

### 离线版本

If you have no internet connection on your development machine or do not want to constantly consume bandwidth for the documentation, you can store the documentation locally, by installing the `openjdk[version]-src` package. Eclipse should find the javadocs automatically.

## 疑难解答

### 自动完成和 javadoc 渲染崩溃

For some reason, libxul may crash. To fix this issue, you can try installing libwebkit[broken link: replaced by webkitgtk2] and adding the following lines in your `/usr/share/eclipse/eclipse.ini`:

    -Dorg.eclipse.swt.browser.UseWebKitGTK=true

If that does not work (or if you do not want to use libwebkit) try this:

  1. Download http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/1.9.0.17/runtimes/xulrunner-1.9.0.17.en-US.linux-i686.tar.bz2
  2. Unpack it into /home/<Username>/.xulrunner (or another location)
  3. Add this line to your Eclipse configuration file `/usr/share/eclipse/eclipse.ini`:

    -Dorg.eclipse.swt.browser.XULRunnerPath=/home/<Username>/.xulrunner

  Now everything should just work fine and tooltips should display correctly.

### 首次启动或选择 "Help->Welcome" 时崩溃

See above.

### Ctrl+X closes Eclipse

Part of this bug. Just look in `~/workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi` and delete the wrong `Ctrl+X` combination. Usually it is the first one.

### Eclipse 4.2.0 not respecting dark/custom gtk themes resulting in white background

Remove or move to backup sub folder all of the .css files from: /usr/share/eclipse/plugins/org.eclipse.platform_4.2.0.v201206081400/css/

Solution source: http://www.eclipse.org/forums/index.php/m/872214/

### Tooltips have dark background color with Gnome 3.6 Adwaita theme

Comment out the second-to-last line in `/usr/share/themes/Adwaita/gtk-2.0/gtkrc` like this

    #widget "gtk-tooltip*"  style "tooltips"

### Toggle buttons states are the same for selected/not selected

Comment out the last line in `/usr/share/themes/Adwaita/gtk-2.0/gtkrc` like this

    #widget "*swt*toolbar*" style "null"

To apply the fixed theme, use `gnome-tweak-tool` to select a different theme and cycle back to Adwaita.

Related bugs:

- https://bugzilla.gnome.org/show_bug.cgi?id=688285
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=381010 (WONTFIX)

Categories:

- Development (简体中文)
- 简体中文