-
Notifications
You must be signed in to change notification settings - Fork 20
Eclipse
- Lars Vogel's Eclipse IDE tutorial
- Our tutorial used in Computer Science MSc education
- Useful hotkeys
If you use multiple Eclipse installations and/or workspaces, putting the workspace title makes it easier to distinguish between them. To do this:
- add
-showlocation
to the end of the shortcut command, - or add the
-showlocation
string on a separate line to theeclipse.ini
file located in Eclipse's folder. - you can also set a custom name in the Preferences | General | Workspace: "Workspace name" without editing the shortcut or the ini
Eclipse, as any other Java application, relies on the JVM to get hold of heap memory. By default, it only reserves a maximum of 512 MB memory which is insufficient if you use many plug-ins or run complex build processes.
As a general rule of thumb, you should go to the Window | Preferences | General window and switch on the Show heap memory checkbox. This way, you always will see if Eclipse is running out of memory.
To increase the amount of heap memory, either edit the eclipse.ini
file or add a switch to your Eclipse shortcut, e.g.
eclipse -data /path/to/your/workspace -showlocation -vmargs -Xmx2G
See also http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F.
Warning for Ubuntu users: If you create a shortcut for Eclipse in the Launcher, it won't use eclipse.ini! See http://stackoverflow.com/a/27168561/90874 This is no longer an issue in Ubuntu 15.04+.
Despite the deceptive name, in general it is best to stick to the Package Explorer instead of the Project Explorer. For example, this shows the projects that are not assigned to any working set under a working set called Other projects.
- Note: the Package Explorer is part of Java Development Tools
You can edit the hotkeys in the Window | Preferences menu, in General | Keys. For some plug-ins (e.g. TeXlipse), the hotkeys do not appear at first: click the Filters... button and untick the Filter uncategorized commands checkbox.
Eclipse does not have the Subversive plug-in installed as standard. This can be installed from the Eclipse version's (e.g. Kepler's) update site. Due to legal reasons concerning the implementation of SVN, an additional component needs to be installed from a separate update site to use Subversive (e.g. SVNKit). The list of possibilities is automatically provided when a team action is first executed (e.g. the SVN Repositories view is opened).
Sometimes projects checked out from SVN will not show the correct actions in the Team menu and the version number and repository is not shown for the folders and files.
- Right click on the project, "Team" -> "Share project" -> "Reconnect"
Remove the fixed console limit in the Preferences: http://steve-brown.id.au/it-stuff/java/eclipse-hangs-on-svn-commit.html
If you use Eclipse's modeling framework (Ecore, EMF), the Eclipse Modeling distribution is recommended. Important note: unlike the Eclipse IDE for Java Developers, this does not have the m2e - Maven Integration for Eclipse plug-in.
Allows easier copy&pasting of file paths, or opening a system file browser at the selected file.
- Install from here: https://marketplace.eclipse.org/content/path-tools
Allows "non-blocking" find-in-file highlighting (Ctrl+Shift+F by default), similar to how web browsers work.
- Install from here: https://marketplace.eclipse.org/content/glance
Launch groups is a useful feature for running multiple applications at once, either in parallel or in sequential order. By default, this feature is only installed in Eclipse CDT, however, you can add it to your Eclipse by installing the C/C++ Remote Launch (Requires RSE Remote System Explorer) feature in the Mobile and Device Development group from your distribution's update site.
If you wish to run the applications in sequential order, go to the Launch Group configuration and use the Edit... menu to set the Post launch action of the individiual launch configurations to Wait until terminated.
Launch groups can also be used from Eclipse Runner (http://marketplace.eclipse.org/content/eclipse-runner). This plug-in provides a separate view for launching applications and is available from the marketplace.
See http://askubuntu.com/questions/40380/how-to-set-an-icon-for-eclipse/. In short, go to Eclipse's directory and issue the following command:
sudo cp icon.xpm /usr/share/pixmaps/eclipse.xpm
If you want to ensure only those plugins are installed that are needed, you can build up your Eclipse installation from the bare minimum. This is called the "Eclipse Platform Runtime Binary":
- http://download.eclipse.org/eclipse/downloads/ Select your preferred version
- Scroll down to Platform Runtime Binary
- Download for the platform of your choice
- You can install additional features (SVN, TeXlipse, JDT, Git etc.) as usual
-
Path tools (available from the Eclipse Marketplace). You may have to set your explorer application under Window | Preferences | Path Tools | Explore Folder, e.g.
nemo "{path}"
in Linux Mint,nautilus "{path}"
in Ubuntu Linux.
-
Symptom: upon adding an update site, you get an error:
Unable to read repository at <repo url>/content.xml. peer not authenticated
-
Problem: the update site might use a self signed certificate, you can check this in a browser, by navigating to
<repo url>
- Solution: You need to add the certificate (if you trust it) to a trust store that Eclipse can see:
- Create a trust store and add it to eclipse.ini: http://eclipsesource.com/blogs/2013/04/19/installing-eclipse-plug-ins-from-an-update-site-with-a-self-signed-certificate/
- Adding the certificate in the Java Control Panel (
javacpl.exe
) should work as well, but it doesn't.
-
Symptom: upon launching, Eclipse throws the following error:
The Eclipse executable launcher was unable to locate its companion shared library.
. - Problem: the path of some components (e.g. plug-ins) is longer than 260 character. This is an old limitation in Windows (see http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath), which is resolved in the Unicode API. However, for some reasons it does not work with Eclipse.
- Solution: move Eclipse to a directory with a shorter path.
Add a new Target Definition which creates a .target
file.
In the Locations group, click Add..., Software Site. Add the following:
- Eclipse update site (e.g. the Kepler update site)
- Eclipse Platform
- EMF - Eclipse Modeling Framework Core Runtime
- Other desired update sites and feature groups.
Click the Downward pointing triangle in the Package Explorer:
- Top Level Elements | Working Sets
- Select Working Set | Select All
This following line in the MANIFEST.MF
file shows an error:
org.junit4;bundle-version="4.8.1"
Threw this error: "Bundle 'org.junit4' cannot be resolved". Changed to
org.junit
This is an Eclipse Kepler-specific issue, Kepler removed the junit4 bundle.
You can turn hard wrapping off by clicking to the downward pointing triangle icon in the commit window and going to the Preferences... window.
Conditional breakpoints are very useful for debugging, see a description here: https://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F. A useful trick is that you may add System.out.println("...")
to the condition.
Symptom: an Eclipse RCP application throws the following error:
!ENTRY org.eclipse.osgi 4 0 2014-08-07 18:57:21.710
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: No application id has been found.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
Problem: there are missing plug-ins: use the Add required plug-ins button is the launch configuration.
If your Eclipse project does not compile, it's often worth trying these steps:
- Use the Save all operation.
- Press Refresh (F5) on the project.
- If it's a Maven project:
- Use the Update Maven project command.
- Make sure that there is no outdated
target
directory. Sometimes the editor uses the Java classes (for content assist and reference resolution), however, the compiler uses the outdated JAR files in thetarget
(or possiblybin
) directory.
- Build the project from command line.
- If it's a Gradle project:
- Right click the parent project, choose Gradle | Refresh Gradle Project.
- Clean the project.
- Clean the workspace.
- Google the error message.
- Close and Open the project.
- Delete the generated files (e.g.
src-gen
,xtend-gen
) manually and clean the workspace. - Restart Eclipse.
- Delete the projects and reimport them.
- Switch to a fresh workspace and import the projects.
- If you are running a runtime Eclipse, run it again and clear its workspace. Go to the Run Configurations. On the Main tab's Workspace Data group, tick the Clear checkbox and run the application. (Don't forget to untick the checkbox later.)
- Check if there are accents (á é etc.) or whitespaces in any paths (e.g. C:/Users/Józsi/myEclipse).
- Ask your boss and/or the local Eclipse expert.
- Consider changing your dependency management and technology stack.
Errors in files containing the dependencies and the classpath (e.g. MANIFEST.MF
, plugin.xml
, pom.xml
, .classpath
) take precedence over other errors (e.g. compile error in Java classes). Fix the former first, else the project cannot possibly work as intended.
Try deleting (or simply renaming) the .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
file.
(source: http://stackoverflow.com/questions/18356963/eclipse-wont-load-workspace)
Sometimes old attributes are stuck in the generated code of the edit
and editor
projects. Of course, this causes compile errors. To get rid of them, do the following:
- Delete the generated edit and editor projects.
- Stop Eclipse.
- You may need to remove the relevant directories in the local Maven repository (
~/.m2
). - Start Eclipse.
- Clean the workspace.
You may need to repeat this as sometimes the cache is very stubborn.
Eclipse Oomph is an installer and updater for Eclipse development environments.
You can accidentally turn off the breadcrumb menu (a toolbar on the top that shows the project/folder/package/class, allowing quick navigation). By default, there are not hotkeys for hiding it, so hit Ctrl
+3
and typo Toggle Java Editor Breadcrumb to turn it off.
Problem: Multiple versions of the same plug-in are required, which causes export of the product to fail: 'Export Product' has encountered a problem:
The detailed error message:
Cannot complete the install because one or more required items could not be found.
Software being installed: codegen 1.0.0.201605030116 (codegen 1.0.0.201605030116)
Missing requirement: Apache Batik Bridge/GVT/Scripting 1.6.0.v201011041432 (org.apache.batik.bridge 1.6.0.v201011041432) requires 'bundle org.apache.batik.css [1.6.0,1.7.0)' but it could not be found
Cannot satisfy dependency:
Solution: Tycho uses a different build mechanism -- if you have a Maven project, it's worth a try to build the product with Tycho and it might just work.
- Problem: The Eclipse executable launcher was unable to locate its companion shared library.
-
Solution: Check if the
~/.p2
directory exists.
-
Install Eclipse Releng Tools from http://download.eclipse.org/eclipse/updates/4.3/.
-
For new files: http://stackoverflow.com/questions/2604424/how-can-i-add-a-default-header-to-my-source-files-automatically-in-eclipse
- Create the plugin.properties file with the variables. Example plugin.properties file:
pluginName = My Plugin providerName = FTSRG
- Use the variables in the MANIFEST.MF or in plugin.xml. Example in MANIFEST.MF:
Bundle-Name: %pluginName Bundle-Vendor: %providerName
- Add the following line to the MANIFEST.MF to activate the usage of plugin.properties:
Bundle-Localization: plugin
- Create a plug-in project with default settings, without an activator.
- Create a class which implements the
IApplciation
interface. - Write your code in the start method and add required plug-ins to the manifest file.
- return
IApplcation.EXIT_OK
- You have to register your
IApplication
implementation as an Extension: - Create an
org.eclipse.core.runtime.applications
extension - Given an ID (convention is just
application
, the project name as a prefix will be given to it) and a Name - Under the extension right click on
(application)
-> New -> run - Set the 'class' property to your IApplication implementation
- Create an
org.eclipse.core.runtime.products
extension - Give an ID (convention is
product
, it will be a postfix) and a Name - Right click -> new -> product
- The
application
will be the previous extension's ID: .application - Also give a name and an optional description to it; You can also add custom properties to this extension
- Don't forget to save and build.
- Create a new Product Configuration from wizard. Put it either to the project or to a separate folder.
- Give it a name (the .product extension will be added automatically) and select "Use an existing product" and select your product extension.
- Give an ID (should be other than your project name, use e.g. a .product postfix), a Version (0.1.0.qualifier), and a Name.
- Product and Application will be selected automagically, however these are your previously defined extensions.
- Under the Dependencies tab add your plug-in and hit Add Required Plug-ins (may have to click twice or thrice).
- Note that if you forget to add any required dependency (e.g. the one that provides the extensions) you will get the following exception later:
[...]
!ENTRY org.eclipse.equinox.app 0 0 2015-05-21 10:42:36.066
!MESSAGE Product <projectname>.product could not be found.
!ENTRY org.eclipse.osgi 4 0 2015-05-21 10:42:36.087
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: No application id has been found.
[...]
- Under the Launching tab you can add Program Arguments. If you want to write on the console you should use a
-consoleLog
argument. Without it sysout has no effect. - Try and run your product by clicking the green-white arrow button on the top right corner of the product configuration file.
- Click the export button on the top right corner of the configuration file.
- Choose a destination and hit finish.
- You can also specify the root directory of the exported eclipse, it is "eclipse" by default (just like when you download an Eclipse distribution)
- Browse the new folder and run the eclipse.exe.
- If you want to configure your Eclipse Product from a file you can use the configuration/config.ini file for that in a 'key=value' format.
- Under the Configuration tab / Properties, you can add custom default key value pairs.
- Use
System.getProperty("key")
to retrieve the value. - Note that this information won't be available and will return null when running from the host eclipse (without exporting the product).
- First of all you will need the delta pack which contains other platform specific jars (e.g. file system).
- You have to edit the target platform to include the delta pack.
- Follow this steps: https://wiki.eclipse.org/Building#Cross-platform_build
- When exporting you will get a new check box: "Export for multiple platforms". Check it and after Next you can specifiy the target platforms.
- Sometimes export errors are written in a logs.zip file
- Vogella tutorial http://www.vogella.com/tutorials/EclipseProductDeployment/article.html
- You can export a jre along with the eclipse by checking the "Bundle JRE..." on the Launching tab
-
Problem: an Eclipse application fails with the error "No application id found".
-
Solution: go to the launch configuration and click Add required plug-ins (multiple times)
-
-
Problem: Eclipse does not start on Ubuntu with
./eclipse: No such file or directory
-
Problem: Eclipse does not start on Ubuntu with
-
- Solution: this is caused by mixing a 64-bit platform with a 32-bit Eclipse. Download the appropriate Eclipse version (http://askubuntu.com/questions/65058/eclipses-executable-file-wont-run-in-ubuntu).
Since Kepler, the PDE provides a useful "Plug-in Image Browser" view in order to support the reuse of different icons contributed by the installed plugins. See details here: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Fviews%2Fimage_browser_view.htm
- Quick AST tutorial (with rewrite) – http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_AST/index.html
- Great presentation and tutorial on the workflow with JDT – [http://www.eclipsecon.org/2012/sites/eclipsecon.org.2012/files/How To Train the JDT Dragon combined.pdf](http://www.eclipsecon.org/2012/sites/eclipsecon.org.2012/files/How To Train the JDT Dragon combined.pdf)
- Report from 2007, summarizes the JDT AST structure and ASTRewrite – http://people.clarkson.edu/~dhou/courses/EE564-s07/AST-Report.pdf
- Parts from the previous presentation:
To use JDT from Maven, use the dependencies on http://repo.eclipse.org, see Maven and Eclipse for details.
<properties>
<jdt.version>3.12.0.v20150913-1717</jdt.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>${jdt.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>eclipse-staging</id>
<url>https://repo.eclipse.org/content/repositories/eclipse-staging/</url>
</repository>
</repositories>
http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/
The latest Eclipse versions (Neon++) support zooming with the keyboard:
- Ctrl + Shift + Num +
- Ctrl + Shift + Num -
If you don't have a numpad or don't want to use the the Num + / Num - keys, you can use the alphanumerical part of the keyboard.
- On an English keyboard (with English layout): Ctrl + Shift + = and Ctrl + -
- On a Hungarian keyboard (with Hungarian layout): Ctrl + Shift + 3 and Ctrl + -.
- On a Hungarian keyboard (with English layout): Ctrl + Shift + ó and Ctrl + ü.
Note: for English keyboards, UK/US should make no difference this time.