Wednesday, July 22, 2015

Eclipse Miscs



https://stackoverflow.com/questions/2635951/eclipse-save-automatically
General > Editors > Autosave > check Enable autosave for dirty editors > choose the value for autosave interval (in seconds)
https://stackoverflow.com/questions/4123628/com-sun-jdi-invocationexception-occurred-invoking-method
The root cause is that when debugging the java debug interface will call the toString() of your class to show the class information in the pop up box, so if the toString method is not defined correctly, this may happen.

I also had a similar exception when debugging in Eclipse. When I moused-over an object, the pop up box displayed an com.sun.jdi.InvocationException message. The root cause for me was not the toString() method of my class, but rather the hashCode() method. It was causing a NullPointerException, which caused the com.sun.jdi.InvocationException to appear during debugging. Once I took care of the null pointer, everything worked as expected.

For me the same exception was thrown when the toString was defined as such:
@Override
public String toString() {
    return "ListElem [next=" + next + ", data=" + data + "]";
}
Where ListElem is a linked list element and I created a ListElem as such:
private ListElem<Integer> cyclicLinkedList = new ListElem<>(3);
ListElem<Integer> cyclicObj = new ListElem<>(4);
...

cyclicLinkedList.setNext(new ListElem<Integer>(2)).setNext(cyclicObj)
    .setNext(new ListElem<Integer>(6)).setNext(new ListElem<Integer>(2)).setNext(cyclicObj);
This effectively caused a cyclic linked list that cannot be printed. Thanks for the pointer.


How to view all items of Errors under Problems View in Eclipse Editor
https://stackoverflow.com/questions/9719605/eclipse-how-to-view-all-items-of-errors-under-problems-view-in-eclipse-editor

How to view all items of Errors under Problems View in Eclipse Editor
Change the Fitter setting as following


http://help.eclipse.org/2018-09/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftips%2Fjdt_tips.html
https://stackoverflow.com/questions/30261645/is-it-possible-to-display-tostring-result-in-value-column-in-eclipse-debugger
Then down below, select "Show variable details > As the label for all variables" (if toString() is enough for you), or "> As the label for variables with detail formatters" if you want to use your custom formatters. The former makes the "Type + ID" display vanish, tho.
Simple formatter for "not toString()": 

Variables View: Show Logical Structure

If you cannot modify the toString-implementation, for example if you are working with frameworks or you have to use a foreign API, it might be an option to create an “Detail Formatter” in Eclipse. To do that, you have to right click an object in the variables view and click on “New Detail Formatter…”. Then you can provide some code to display this type of Object in the future.
A cycle was detected in the build path of project
https://www.eclipse.org/forums/index.php/t/95704/
- Preferences -> Java-> Compiler -> Building -> Circular Dependencies, change it from Error to Warning
https://www.eclipse.org/eclipse/news/4.9/jdt.php
A new quick fix has been implemented that allows the user to convert static field accesses and static methods to use a static import. It's also possible to replace all occurrences at the same time.
A new option in the Source > Generate hashCode() and equals()... tool allows you to create implementations using the Java 7 Objects.equals and Objects.hash methods.


Additionally, arrays are handled more cleverly. The generation prefers the Arrays.deepHashCode and Arrays.deepEquals methods when dealing with Object[], Serializable[] and Cloneable[] or any type variables extending these types.


A new option has been introduced in the Debug view to show or hide running threads.
Hiding running threads can be useful when debugging heavily multithreaded application, when it is difficult to find threads stopped at breakpoints among hundreds or thousands of running threads.

https://wiki.eclipse.org/FAQ_How_do_I_upgrade_Eclipse_IDE%3F
  1. enable the Latest Eclipse release http://download.eclipse.org/releases/latest repository by ticking the checkbox.
Upgrading existing Eclipse IDE and Installed Features to newer release
To upgrade Eclipse IDE to the next major release

You first need to add the new release's repository as follows:
Window > Preferences > Install/Update > Available Software Sites

https://bugs.eclipse.org/bugs/show_bug.cgi?id=290782
The workaround "disable contact all update sites" still applies
https://www.eclipse.org/eclipse/news/4.9/
The Eclipse SDK project is part of the 2018-09 release, Eclipse Foundation's first quarterly Simultaneous Release, available September 19, 2018.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=197850
Add Import on static methods is delicious!  We all love you.  It's Ctrl-Shift-M by the way.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=197850
+ A new quick fix has been implemented that allows the user to convert static field accesses and static methods to use a static import.
+ It's also possible to replace all occurrences at the same time.
http://www.lorenzobettini.it/2017/12/formatting-java-method-calls-in-eclipse/
You can configure the Eclipse Java formatter with that respect; you just need to reach the right option (the “Force split” is necessary to have each invocation on a separate line):

- [Function calls -> Qualified invocations](http://www.lorenzobettini.it/2017/12/formatting-java-method-calls-in-eclipse/)
  - Wrap all elements, except first element if not necessary, and don't select "Force split"


https://stackoverflow.com/questions/10400978/how-to-toggle-visibility-of-a-view-in-eclipse-with-a-keyboard-shortcut
There is a command for "Minimize Active View or Editor" that you can assign a keyboard shortcut to, but there doesn't seem to be a similar command for Restore. I suppose that's because a minimized view can't have focus or be "active" and so there's no context in which a Restore command could be utilized.
The problem with Minimize Active View or Editor is that after minimizing a view all subsequent show actions show the view as if it was Fast View.
https://stackoverflow.com/questions/21481370/eclipse-force-javadoc-hover-on-element-that-has-a-warning
  - Press Command+Shift while hover
- [Show variable values while debugging]
  - Press Command while hover (added)

https://stackoverflow.com/questions/1212633/can-eclipse-refresh-resources-automatically
Out of synchronization problem is common in eclipse IDE so you have to check this option windows -> preference -> Workspace -> refresh using native hooks or polling.
https://www.codeaffine.com/2016/04/19/terminate-relaunch-eclipse/
Terminate and Relaunch in Eclipse

http://www.webtrafficexchange.com/how-exclude-certain-folders-eclipse-search

Code template

https://howtodoinjava.com/tools/eclipse/create-eclipse-templates-for-faster-java-coding/
http://fahdshariff.blogspot.com/2011/08/useful-eclipse-templates-for-faster.html

https://www.eclipse.org/eclipse/news/4.8/

https://stackoverflow.com/questions/957822/eclipse-unable-to-install-breakpoint-due-to-missing-line-number-attributes
I tried almost every solution here and no luck. Did you try clicking "Don't tell me again"? After doing so I restarted my program and all was well. Eclipse hit my breakpoint as if nothing was wrong.
The root cause for me was Eclipse was trying to setup debugging for auto-generated Spring CGLIB proxy objects. Unless you need to debug something at that level you should ignore the issue.
https://stackoverflow.com/questions/1028858/useful-eclipse-java-code-templates
SLF4J
${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class);
Log4J 2
${:import(org.apache.logging.log4j.LogManager,org.apache.logging.log4j.Logger)} 
private static final Logger LOG = LogManager.getLogger(${enclosing_type}.class); 
Log4J
${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);
http://www.pellegrino.link/2011/05/14/eclipse-sysargs-code-templates.html
Go to PreferencesJavaEditorTemplates. Then, click on the Newbutton and enter the name sysargs for your new code template. Finally, copy/paste the following piece of code as pattern.
System.out.println(
  "${enclosing_package}.${enclosing_type}#${enclosing_method}(${enclosing_method_arguments}) = ("
    + Arrays.toString(new Object[] {${enclosing_method_arguments}}) + ")");
sysout is expanded to:
System.out.println(${word_selection}${});${cursor}
https://matsim.org/docs/devguide/eclipse/jdk
https://stackoverflow.com/questions/12446316/which-java-is-eclipse-using
To check with what Java version (JRE or JDK) Eclipse is running, do the following:
  • Open the menu item Help > About Eclipse. (On the Mac, it’s in the Eclipse-menu, not the Help-menu)
  • Click on Installation Details.
  • Switch to the tab Configuration
  • Search for a line that starts with -vm. The line following it shows which Java binary is used.
Depending on the name and location of the used Java binary one can figure out if a JRE or a JDK is used:
  • If the path contains “jre” (e.g. as in C:\Program Files\Java\jre6\bin\client\jvm.dll) it is a JRE
  • If the path contains “jdk” (e.g. as in C:\Program Files\Java\jdk1.6.0_31\bin\javaw.exe) it is a JDK.



















  • Go to the Eclipse installation directory and open the file eclipse.ini in a text editor.
  • Search for the line -vmargs
  • Before the line -vmargs, add two lines:
    On the first line, write -vm
    On the second line, write the path to your JDK installation (usually something like: C:\Program Files\Java\jdk1.6.0_31\bin\javaw.exe on Windows)
https://stackoverflow.com/questions/12411750/maximize-code-tab-in-eclipse-shortcut
CtrlM will maximize/restore the editor area.
If you can't remember all shortcuts, then just learn CtrlShiftL. That will show a list of available shortcuts.
https://stackoverflow.com/questions/21405973/what-is-the-shortcut-in-eclipse-to-go-half-a-page-up-and-down
function + up/down - page up/down

open -n /Applications/Eclipse.app/
https://stackoverflow.com/questions/10161470/whats-the-shortcut-of-switching-between-different-perspectives-in-eclipse/25344004
To switch between perspectives.
  • Windows: Ctrl+F8
  • Mac: cmd+F8
https://stackoverflow.com/questions/1209505/right-click-keyboard-short-cut-for-eclipse
As of Eclipse Juno, Shift+F10 works on Mac to bring up the context menu. It's mapped in Preferences | Keys as Show Context Menu.
https://www.infoq.com/news/2018/04/eclipse-photon
  1. The Project Properties dialog now features a page to add or remove Natures on a project.
  1. Workspaces can now build projects in parallel via a setting on the Workspace Preferences page.
https://www.eclipse.org/eclipse/news/4.7/jdt.php
Warnings for unlikely argument types
Remote Java Application "Socket Listen" type supports multiple incoming connectionsThe Remote Java Application debug configuration's Standard (Socket Listen) connection type now supports incoming connections from multiple VMs. This is useful for debugging distributed systems. The connection limit may be set to a fixed number, or 0 for unlimited connections.
Show JUnit failure trace in Console view
https://marketplace.eclipse.org/content/extras-eclipse
http://blog.vogella.com/2015/10/09/eclipse-neon-and-saneclipse-adding-full-screen-mode-for-eclipse/
trigger a “Full Screen mode
https://stackoverflow.com/questions/9321408/hide-unit-tests-from-call-hierarchy
  1. In the Call Hierarchy view, click the white downwards arrow icon.
  2. Select "Filters".
  3. Check "Name filter patterns (matching names will be hidden)".
  4. Depending on your naming convention, enter the name pattern that shows-up test classes (e.g. if they end with "Test" then enter *Test).
  5. Click the refresh button (or press F5)
The test classes and methods should not be visible anymore.
You can define a Working Set that only includes Java source but excludes your unit tests, then select Search Scope > Working Set... in the Call Hierarchy view menu.
https://stackoverflow.com/questions/3962195/filter-eclipses-open-call-hierarchy-to-just-my-company-project
I had the same problem lately and exploring the options of the Call Hierarchy led me to the Search In option. It is activated by clicking on the triangle

https://stackoverflow.com/questions/17565408/force-eclipse-to-ignore-tests-classes-for-java-search?rq=1
Or you can create 2 working sets. 1 set for your code and a second one for your tests. Then when you search, you can search only the working set that holds the code.
  • Open Search dialog (ctrl+h)
  • Change search scope to Working Set
  • Click Choose ...
  • Click New to create a new Working Set with the what you want searched (or Add All and then remove the ones you want filtered

https://stackoverflow.com/questions/118243/open-multiple-eclipse-workspaces-on-the-mac
By far the best solution is the OSX Eclipse Launcher presented in http://torkild.resheim.no/2012/08/opening-multiple-eclipse-instances-on.html It can be downloaded in the Marketplace http://marketplace.eclipse.org/content/osx-eclipse-launcher#.UGWfRRjCaHk
File -> Open Workspace
http://marketplace.eclipse.org/content/osx-eclipse-launcher#.UGWfRRjCaHk
OS X Eclipse Launcher
https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-15.htm
Use eclipse Scrapbook page to run ad-hoc code.
https://marketplace.eclipse.org/content/spotbugs-eclipse-plugin

Eclipse troubleshootings
Eclipse OSGI console
ss | grep INSTALLED
https://www.ibm.com/developerworks/library/os-ecl-osgiconsole/

https://dzone.com/articles/problems-eclipse-36-helios
Help > About > Installation Details showed they were installed but none were shown on Features or Plug-ins tabs. Apparently installed doesn’t mean installed in the typical sense of the word.

  • starting eclipse with -clean didn’t seem to help
  • starting eclipse with -consoleLog -debug didn’t turn up anything
  • starting eclipse with -console and using the ss command on the osgi console did not turn up the wayward plugins
http://blog.zvikico.com/2010/08/eclipse-plugin-installation-and-windows-user-access-control.html
http://blog.zvikico.com/2009/07/ten-tips-for-installing-plugins-in-eclipse-galileo.html

https://stackoverflow.com/questions/33858411/where-is-the-location-of-plugins-directory-for-eclipse-mars-in-mac-osx
In my case (Mars on Mac version Darwin 14.5.0, installed with Eclipse installer) I found the plugins folder in MY_HOME_DIRECTORY/.p2/pool/plugins . I found this path with this: Eclipse -> About Eclipse -> Installation Details -> Configuration -> property --launcher.library
https://stackoverflow.com/questions/2697882/plugins-installed-on-eclipse-not-visible
Have you tried running Eclipse with the -clean argument ? You need to do this only once and not every time you start Eclipse, you it is recommended to do so after a plugin installation.
If that doesn't help, verify if you have privileges to write onto the features and plugins subdirectories. The plugin installation process requires the write privilege, but I've never seen a plugin installation succeed without one; still, it is worth checking for.

ss | grep RESOLVED
https://dzone.com/articles/problems-eclipse-36-helios

https://wiki.eclipse.org/Eclipse.ini

https://www.eclipse.org/eclipse/news/4.7/jdt.php
This makes use of another new feature of conditional breakpoints: As long as the condition doesn't explicitly return a boolean true, the condition is now considered to implicitly return false, and the breakpoint will not suspend execution.
You can now disable Hot Code Replace (HCR) if it causes any trouble or if you want to avoid code changes in a debug target. HCR is enabled by default but can be disabled in Preferences > Java > Debug.
The Refactor > Rename popup now shows an Options... link which opens the full Rename dialog that provides more options like renaming a field's getter and setter methods.

https://www.eclipse.org/eclipse/news/4.5/jdt.php
Ctrl+Alt+B has been added as the shortcut for Skip All Breakpoints.

https://stackoverflow.com/questions/2805803/need-to-refactor-field-names-in-eclipse-which-should-change-getters-setters-as-w
Yes, in Galileo the "rename" dialog has an option for changing the setters and getters of a field - see here. (Alternatively, you can use ALT + SHIFT + R twice after selecting the field)
https://stackoverflow.com/questions/7672880/is-there-an-eclipse-shortcut-behaves-just-like-double-click-using-mouse
Regarding the next TODO/FIXME position, there are 2 buttons in the toolbar - 'Previous Annotation' (the icon has an up arrow) and 'Next Annotation' (the icon has a down arrow) - which allow you to move from one annotation to another. Annotations are the markers in the editor - errors, warnings, breakpoints, TODOs etc. You can configure which annotations should the buttons traverse through by clicking on the dropdown (inverted triangle) icon next to the toolbar buttons.
Keyboard shortcut for 'Next Annotation' is 'Ctrl+.', these are also shown if you hover over the toolbar buttons.
PS: You might also find it useful to glance through the JDT tips and tricks document. The above mentioned toolbar buttons are also described in the document.

eclipse marker id not found
- reopen the java class in editor

http://www.eclipse.org/community/eclipse_newsletter/2017/june/article1.php
Now users can activate Trigger Point. A set of trigger points can be defined for the breakpoints in a workspace.
All the other breakpoints that are initially suppressed by triggers will be hit only after any of the all Trigger Points have been hit. All the triggers are disabled after a Trigger Point is hit and will be re-enabled after the run.
Launch Group

https://stackoverflow.com/questions/12269059/eclipse-annoying-thread-switching-while-debugging-a-threads-execution
Once you've stopped on a breakpoint, select that breakpoint and select "Breakpoint Properties" from the context menu. On the filter tab there is a list of threads that you can restrict the breakpoint to. You'll have to set that filter on any other breakpoint you also want to stop on in the thread.
https://stackoverflow.com/questions/15201367/eclipse-javadocs-popup-font-size
Preferences -> Appearance -> Colors and Fonts -> Java -> Javadoc Display Font
http://www.codejava.net/ides/eclipse/how-to-add-copyright-license-header-for-java-source-files-in-eclipse

1. Modifying Code Templates

In this way, we use a built-in feature of Eclipse. Click Window > Preferences to launch the Preferences dialog. Then expand the tree on the left to the branch Java > Code Style > Code Templates:
Then expand the branch Code > New Java files under the section ‘Configure generated code and comments’. We are going to modify code template of every new Java file created afterward, so click Edit button. In the Edit Template dialog, insert some sentences for your copyright license into the Pattern text area:
https://github.com/kohanyirobert/eclipse/blob/master/java-code-style-organize-imports.importorder
https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Fcodestyle%2Fref-preferences-organize-imports.htm

https://github.com/trylimits/Eclipse-Postfix-Code-Completion
No need for this plugin
.var - we can use ctrl+1 quick fix.

http://www.programmingforliving.com/2013/06/remove-eclipse-error-a-cycle-was-detected-in-build-path.html
Modularizing the projects in a proper way by eliminating the circular dependencies is the right thing to do here, but that is out of the scope of my work. What I can do here is to make eclipse ignore circular dependencies so that I would be able to build my project.
You can go to Window -> Preferences -> Java -> Compiler -> Building and change the Error to Warning.

https://stackoverflow.com/questions/4174549/how-to-show-a-list-of-spelling-suggestions-in-the-default-eclipse-xml-editor
In Eclipse Luna, XML spell check works great with CTRL + 1:
https://stackoverflow.com/questions/5574831/kill-eclipse-background-operation-without-killing-eclipse
If you go to window Progress in Eclipse and click red square to Stop:
Stopping Wildfly 9.x
and next, red square becomes gray square and process i frozen (Cancel Requested):
eStopping Wildfly 9.x Cancel Requested
You must use Task Manager (Alt+Ctrl+Del on Windows) for kill process. Go to tab Processes, find process javaw.exe* and click End Process.
The result: frozen process in Eclipse was closed but your Eclipse wasn't closed.
* Process with name javaw.exe is for WildFly server. For Subclipse SVN can be another name of proces.
http://wiki.eclipse.org/FAQ_Where_is_the_workspace_local_history_stored%3F
Lets assume that you lost your file on Jun 12
  cd .metadata/.plugins/org.eclipse.core.resources/.history/
  ls -al * | grep "Jun 22" | grep "r\-\-" | sort -k 6
Local History -> compare/replace/restore with

https://stackoverflow.com/questions/33785727/the-type-org-eclipse-jdt-annotation-nonnull-cannot-be-resolved-it-is-indirectly
Another option is to disable the annotation-based null analysis feature in Eclipse.
Open the global or project settings and go to Java > Compiler > Warnings. In the Null analysiscategory, uncheck Enable annotation-based null analysis.
The workspace will have to be rebuild and those errors won't show again.
https://stackoverflow.com/questions/19030954/cant-find-nullable-inside-javax-annotation
Can't find @Nullable inside javax.annotation.
You need to include a jar that this class exists in. You can find it here
If using Maven, you can add the following dependency declaration:
<dependency>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>jsr305</artifactId>
    <version>3.0.2</version>
</dependency>
https://marketplace.eclipse.org/content/moreunit
http://moreunit.sourceforge.net/
MoreUnit identifies the method under the cursor and generates a test method stub.
http://stackoverflow.com/questions/5131897/how-to-create-unit-tests-easily-in-eclipse
To create a test case template:
"New" -> "JUnit Test Case" -> Select "Class under test" -> Select "Available methods". I think the wizard is quite easy for you.
https://stackoverflow.com/questions/3004846/keyboard-shortcut-to-switch-between-test-and-class-in-eclipse
http://moreunit.sourceforge.net/
  • jump to test(ed) files/methods corresponding to the element your are editing (Ctrl-J by default). If none exists, it proposes you to create it.
  • run test classes/methods from the class under test (Ctrl-R by default).
  • generate a test method stub for the method under your cursor.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403464
The size of all my workspaces have exploded because of 
.metadata/.plugins/org.eclipse.m2e.core
m2e creates and maintains three copies of remote repository indexes -- 

* per repository packed .gz index under ~/.m2/repository/.cache
* per repository/m2e version unpacked lucene under ~/.m2/repository/.cache
* per workspace unpacked lucene under .metadata/.plugins/org.eclipse.m2e.core/nexus
In the short term, you can disable indexes in Maven Repositories view and delete cached indexes from locations specified above.

I uninstalled the m2e plug-ins and deleted every occurrence of org.eclipse.m2e.core that I could find :-) 

The same Lucene index can't be used by multiple JVMs concurrently.

Automatic index download is now disabled by default (Bug #404417), so this shouldn't really be a problem anymore, at least until one forces index download.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404417
Users who do want to continue updating the index will need to change the preference "Download repository index updates on startup".
How to search for text in package in Eclipse?
http://stackoverflow.com/questions/5023716/is-there-a-way-to-search-for-text-in-package-in-eclipse
Click on the package in Package Explorer, then hit Ctrl-H and click 'Selected Resources'
https://wiki.eclipse.org/FAQ_Where_is_the_workspace_local_history_stored%3F
  cd .metadata/.plugins/org.eclipse.core.resources/.history/
  ls -al * | grep "Jun 22" | grep "r\-\-" | sort -k 6

http://stackoverflow.com/questions/1541787/eclipse-plugin-to-find-out-unused-methods-in-a-class-package
https://marketplace.eclipse.org/content/unnecessary-code-detector
An Eclipse plugin that works reasonably well is Unused Code Detector.
It processes an entire project, or a specific file and shows various unused/dead code methods, as well as suggesting visibility changes (i.e. a public method that could be protected or private).
http://stackoverflow.com/questions/7977789/how-increase-number-of-files-shown-in-recently-opened-files-list
     General -> Editors
and you'll find an option that says
     Size of recently opened files list

tomcat eclipse missing line number attributes
http://stackoverflow.com/questions/20344230/breakpoint-error-when-debugging-in-eclipse-how-to-fix-it
I have had the same problem, but reading your post helped me resolve mine. I changed org.eclipse.jdt.core.prefs as follow:
BEFORE:
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
AFTER:
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
http://stackoverflow.com/questions/957822/eclipse-unable-to-install-breakpoint-due-to-missing-line-number-attributes

An internal error occurred during: “Updating Maven Project”. java.lang.NullPointerException
http://stackoverflow.com/questions/19522897/an-internal-error-occurred-during-updating-maven-project-java-lang-nullpoint
I solved mine by deleting the .settings folder and .project file in the project and then reimporting the project.
- <artifactId>${the-artifactId-property}</artifactId>
- this doesn't work - the property name substitution doesn't work

yourWS/.metadata/.log

http://stackoverflow.com/questions/118243/open-multiple-eclipse-workspaces-on-the-mac
cd /Applications/eclipse/

open -n Eclipse.app
By far the best solution is the OSX Eclipse Launcher presented in http://torkild.resheim.no/2012/08/opening-multiple-eclipse-instances-on.html It can be downloaded in the Marketplace http://marketplace.eclipse.org/content/osx-eclipse-launcher#.UGWfRRjCaHk
https://marketplace.eclipse.org/content/os-x-eclipse-launcher

How to share eclipse configuration over different workspaces
http://stackoverflow.com/questions/2078476/how-to-share-eclipse-configuration-over-different-workspaces
Another option is export/import:
  1. From your existing workspace, File->Export...->General->Preferences, check Export all, and choose file to save them to (prefs.epf for example)
  2. Startup Eclipse in a new workspace, File->Import...->General->Preferences , choose your file (prefs.epf), check import all
That worked great for the original author of this tip: he had his code formatting, code style, svn repos, jres preferences imported.
Edit: On Eclipse Juno this works poorly. Some preferences silently do not carry over such as save actions.
If you want preserve all your settings, simply copy the
.metadata/.plugins/org.eclipse.core.runtime/.settings 
directory into your desired workspace directory
You can also export the preferences you set in the template workspace and then import them into other workspaces. This is the preferred method supported by Eclipse.
Hot deploy
http://www.mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/
2.1 Double clicks on the Tomcat plugin, refer to publishing tab, make sure Automatically publish when resources change is selected. This should be the default option, to support “hot deploy” resources, for example : JSP, XML and properties files.

2.2 In the Tomcat Plugin page, clicks on the Module view, make sure Auto Reload is Disabled. Default is enabled.
This is an important step, failed to set the auto reload to disabled, the Tomcat server will be restarted every time you modified something!

Hot deploy has supported the code changes in the method implementation only. If you add a new class or a new method, restart is still required.

http://stackoverflow.com/questions/19793895/run-mvn-clean-install-in-eclipse
Once you have this installed, you should be able to run all the maven commands. To do so, from the package explorer, you would right click on either the maven project or the pom.xml in the maven project, highlight Run As, then click Maven Install.
http://blog.deepakazad.com/2012/06/jdt-tip-toggle-between-inserting-and.html
When content assist is invoked on an existing identifier, it can either replace the identifier with the chosen completion or do an insert.

The default behavior is to insert. You can toggle this behavior while inside the content assist selection dialog by pressing and holding the Ctrl key while selecting the completion. The highlighted text is overwritten.

If you wish the completion to overwrite without pressing the Ctrl key then you can select 'Preferences > Java > Editor > Content Assist > Completion overwrites'.
http://stackoverflow.com/questions/3935445/select-which-method-to-step-into-in-debugger
While debugger is stopped on a break point, put cursor on a method you want to step into and then use Run menu / Step Into Selection (Ctrl-F5) or just Ctrl+Alt-Click on that method in the editor.
https://blog.jetbrains.com/idea/2013/10/smart-step-into-for-anonymous-classes-and-lambdas-in-intellij-idea-13/


Eclipse autosave
https://bugs.eclipse.org/bugs/show_bug.cgi?id=34076
https://bugs.eclipse.org/bugs/show_bug.cgi?id=486644
https://wiki.eclipse.org/Platform_UI/AutoSave
*The period of inactivity before automatic save will be customizable in Eclipse Preferences (from Window > Preferences > General > Editors > Auto-save).

Word wrap in text editorsToggle Word Wrap button has been added to the workbench toolbar. Shortcut: Alt+Shift+Y.
Substring code completion
http://marketplace.eclipse.org/content/smart-save
https://projects.eclipse.org/development_effort/implement-auto-save-editors

https://www.eclipse.org/eclipse/news/4.6.2/
https://www.eclipse.org/eclipse/news/4.6/jdt.php
ifNotNull/ifNull templatesThe Java editor now offers default templates for creating "== null" and "!= null" checks.
Clean Up to remove redundant type argumentsA new option to remove redundant type arguments has been added under the "Unnecessary Code" group of the Clean Up profile.
Create new fields from method parametersYou can now assign all parameters of a method or constructor to new fields at once using a new Quick Assist (Ctrl+1):
Quick Fix to configure problem severityYou can now configure the severity of a compiler problem by invoking the new Quick Fix (Ctrl+1) which opens the Java > Compiler > Errors/Warnings preference page and highlights the configurable problem.
Installing breakpoints from unrelated projectsMultiple versions of the same Java type can be available in a workspace, and each version can have breakpoints configured at different source locations. When debugging, JDT tries to determine the "right" set of breakpoints to install in the target VM. This analysis now uses Java project dependencies by default.
To always install all enabled breakpoints, you can disable the new option Preferences > Java > Debug > Do not install breakpoints from unrelated projects

Enabled assertions for new JUnit launch configurationsAssertions are now enabled by default for new JUnit launch configurations. You can disable this on Preferences > Java > JUnit page:

Commands and shortcuts to zoom in text editorsIn text editors, you can now use Zoom In (Ctrl++ or Ctrl+=) and Zoom Out (Ctrl+-) commands to increase and decrease the font size.
Like a change in the General > Appearance > Colors and Fonts preference page, the commands persistently change the font size in all editors of the same type. If the editor type's font is configured to use a default font, then that default font will be zoomed.
Pinch to zoom in text editorsTo temporarily zoom the editor font in text editors, use a "pinch" gesture on a touchpad. Put two fingers on the touchpad and move them apart or together.
To reset the original font size, rotate two fingers by at least 45°, or close and reopen the editor (Navigate > Back).
On the Mac, Window > Toggle Full Screen (Control+Command+F) still works as before.
You can disable the CSS-based styling of the Eclipse IDE via Preferences > General > Appearance > Enable theming. This will prevent Eclipse from rendering custom colors, shades, and borders, and may result in better performance.

Advanced capabilities preferences are now displayed in place (no extra dialog)Previously, the entries in the Capabilities preference page were displayed in a list. If you wanted to edit them, you had to open an extra dialog. Now you can directly enable or disable the capabilities from the preference page, as depicted in the following screenshot.

Rename optionsThe Refactor > Rename popup now shows an Options... link which opens the full Rename dialog that provides more options like renaming a field's getter and setter methods.
http://www.slideshare.net/kthoms/boosting-the-performance-of-your-eclipse-ide-eclipsecon-france-2016
OS indexes every changed file
Consumes CPU & IO
Usually senseless for build
output and workspace
metadata
Can only be disabled easily for
directories, not by file types
Programmatically:
Spotlight: Flag File
.metadata_never_index
Windows:
attrib.exe /s –i *.*

RAM Disk
What to store?
Read-only Data
JRE
Bundle Pool
Output folders
Use Symbolic Links
Store / Restore state to/from
persistent storage

Eclipse Installation

Don’t install every feature any team member might use
Different feature set for different tasks?
Expensive: Mylyn, Subversion
Use Oomph setups or Eclipse Profiles

Deactivate unimportant Startup Plug-ins
Disable Spell Checking
Disable Code Folding
Suspend unnecessary Validators
Apperance:
Disable Animations
Disable unnecessary Decorations

Maven:
Disable download repositery index on startup
User interface: open xml page in the pom editor by default

Avoid copying .gitignore
Cleanup Metadata
Clean JDT index
<WS>\.metadata\.plugins\org.eclipse.jdt.core
Resource History
<WS>\.metadata\.plugins\org.eclipse.core.resources\.history
PDE caches / Bundle Pool
<WS>\.metadata\.plugins\org.eclipse.pde.core
or even fresh workspace
http://mishadoff.com/blog/eclipse-speedup/
By the way, some plugins appeared due to your experimenting and not used anymore. Delete redundant plugins if they not used at all.
Help -> About Eclipse SDK -> Instalation Details -> <Select plugin> -> Uninstall

Disable autobuild


Probably, you aware about when you want to build your project and when not.

Project -> Uncheck 'Build Automatically'
Window -> Preferences -> Java -> Compiler -> Building -> Uncheck 'Scrub output folders when cleaning'
Window -> Preferences -> Java -> Compiler -> Building -> Uncheck 'Rebuild class files modified by others'
Use Separate Eclipse Install for Projects with Different Plugin needs

Memory/Hardware Related Tweaks
Use RamDisc

Putting the JVM in RAM Disk may improve the performance. RAM Disk is a freely available option on linux systems

Reboot/Restart your system often
Doing occasional restarts within a week is going to keep your system faster. 

Close Unwanted Projects
Disable Auto Validation
Disable Automatic Build
Disable Label Decorations

  • eneral > Startup and Shutdown : remove all plugins activated on startup
  • General > Editors > Text Editors > Spelling : Disable spell checking
  • General > Validation > Suspend all
  • Window > Customize Perspective > Remove stuff you don’t use or want (shortcut keys are your friends), same for Menu Visibility (how many times have you printed a source file…)
  • Install/Update > Automatic Updates > Uncheck “Automatically find new updates”
  • General > Appearance > Uncheck Enable Animations
  • Stay with the default theme. Unfortunately, anything else makes it really laggy and slow.
{workspace path}/.metadata/.plugins/org.eclipse.jdt.core
{workspace path}/.metadata/.plugins/org.eclipse.core.resources/.history

ou can disable it by adjusting plugin configuration parameters as shown on the image bellow: enter image description here

Then you can remove .metadata/.plugins/org.eclipse.m2e.core/nexus directory from your workspace.
Generally web apps are deployed in one of the directories in .metadata and that's generallay the reason of large size
.metadata\.plugins\org.eclipse.wst.server.core
  1. Delete the cache from .m2/repository/.cache/m2e.
  2. Open your eclipse
  3. Menu Windows > Preferences > Maven > User Settings > Update Settings
m2e caches lucene index in two places. Per-workspace indexes are stored under .metadata/.plugins/org.eclipse.m2e.core/nexus and there is also global cache in ~/.m2/repository/.cache/m2e/${m2e.version}.
Try cleaning the caches and see if the problem goes away.
https://dzone.com/articles/your-eclipse-running-bit-slow

https://codeyarns.com/2014/11/07/how-to-remove-feature-or-plugin-in-eclipse/
  1. Go to Help -> Installation Details. Click the tab Installed Software.
  2. Choose any of the features or plugins here and click on Uninstall at the bottom-right of this dialog to remove it.
http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-capabilitiespref.htm
disable team and terminal capabilities

http://jtuts.com/2015/12/09/disable-git-functionality-for-a-project-in-eclipse/
  1. Right click on a project in the Package Explorer.
  2. Click on Team -> Disconnect
Ok, here's a suggestion. You can disconnect the particular project from Egit by doing the following: Right click on project->Team->Disconnect.
When you do wish hookup to the repo again, do right-click on project->Team->Share Project...

Disable plugins at startup
General -> Startup and Shutdown
m2e marketplace

Disable build automatically - but don't forget to enable it before deploy to tomcat

https://dzone.com/articles/your-eclipse-running-bit-slow
disable all validators

http://jmini.github.io/blog/2016/2016-04-24_disable_eclipse_theming.html
with Neon you can deactivate the theming (appearance section of the preferences) completely. In that case the CSS styling engine will be deactivated and your Eclipse IDE will have a really raw look

https://zeroturnaround.com/rebellabs/eclipse-having-a-slow-day-speed-it-up-in-a-few-clicks/
-XX:PermSize=256m
-XX:MaxPermSize=256m
-XX:+UseParallelGC ==> java 8 -XX:+UseG1GC
-Xms512m
-Xmx1024m

Excessive indexes and history


https://www.optaplanner.org/blog/2015/07/31/WhatIsTheFastestGarbageCollectorInJava8.html
  • G1 focuses on limiting GC pauses, instead of throughput. For these use cases (with heavy calculations) GC pause length mostly doesn’t matter.
Class verification is where the JVM sifts through your class files when they’re loaded and verifies that class data is not corrupt or invalid. This is only really important if you’re manipulating byte code anyway. Plugins also go through the same checks and this can be a big overhead. We’re talking 10-20% startup improvement. So how can you fix it? Well, you need to use the -Xverify:noneoption on your JVM, which disables class verification

Add -Xverify:none to your eclipse.ini file.
It will cut down your Eclipse startup time considerably (50% in my case if not more). This will tell the VM not to validate all the .class files it is loading.
https://zeroturnaround.com/rebellabs/using-eclipse-for-java-development/4/


http://howtodoinjava.com/optimization/how-to-quickly-make-eclipse-faster/
Cleaning up history and indexes reduce the load on RAM, and overall HDD usage as well. This result in very high impact on performance. To remove the indexes and history folders, please cleanup all files/folders inside these two folders:
For cleaning up indexes
{workspace path}\.metadata\.plugins\org.eclipse.jdt.core
For cleaning up history
{workspace path}\.metadata\.plugins\org.eclipse.core.resources\.history
The JVM runs in two modes, -server and -client. If you use the default -client mode, there will be a faster start-up time and a smaller memory footprint, but lower extended performance. You can enhance performance by using -server mode if a sufficient amount of time is allowed for the HotSpot JVM to warm up by performing continuous execution of byte code. In most cases, use -server mode, which produces more efficient run-time execution over extended periods. 


https://www.youtube.com/watch?v=UE9BjyZxN3U

http://stackoverflow.com/questions/118243/open-multiple-eclipse-workspaces-on-the-mac
This seems to be the supported native method in OS X:
cd /Applications/eclipse/

open -n Eclipse.app
Be sure to specify the ".app" version (directory); in OS X Mountain Lion erroneously using the symbolic link such as open -n eclipse, might get one GateKeeper stopping access

By far the best solution is the OSX Eclipse Launcher presented in http://torkild.resheim.no/2012/08/opening-multiple-eclipse-instances-on.html It can be downloaded in the Marketplace http://marketplace.eclipse.org/content/osx-eclipse-launcher#.UGWfRRjCaHk
http://ganeshtiwaridotcomdotnp.blogspot.com/2011/09/some-useful-regular-expressions-for.html
Pattern 3 : Finding myVar1, myVar2, myVar3ab, myVar5 etc. but not myVar4
SearchString :: myVar[^4]

Pattern 5:  Finding some character at end of line
e.g. : finding   null); at the end such as :
doSth(str, null);
callFunction(param1,null);
SearchString :: null\)\;$ 

NOTE: regex$Finds regex match at the end of the line
Pattern 6 : finding the patterns like
textArea.setText("jpt");
textArea2.setText("jptsdfsdf");
textArea2.setText("jptsdfsdf");

SearchString :: \S*\.setText\S*

 \S represents a non-whitespace character, and \S* means  any length of some non-whitespace character.
Pattern 7 : finding the comments like (with single word)
SearchString :: \/\/[\S]*$

Pattern 8 : finding blank lines 
SearchString : ^\s*\r?\n
Pattern 9 : finding blank lines  and remove it

SearchString :: ^\s*\r?\n

Replace with ::         <--EMPTY 
Pattern 10 : finding a group and replace
To extract parts of a string that have been matched using the grouping metacharacters, use the special variables $1, $2, etc.
TO FIND : property.someMethod()
TO REPLACE WITH : ((Object)property.someMethod());

In this case we should find "property.someMethod()" and append "((Object)" at first and ");" at end.
SearchString : (property.someMethod\(\))

Replace With : (Object)$1);

Pattern 11 : More complex finding and replacing a group 
TO FIND: 
value[0] = 100;
value[1] = 131;

value[2] = 102; 

value[3] = 123; 


....

Desired Output:
value[0] = getValue(0,100);

value[1] = getValue(1,131);

value[2] = getValue(2,102); 

value[3] = getValue(3,123); 
...


Here we should find two groups $1 = 0,1,2,3 ... $2= 100,101,102,...
SearchString :  (\d+)\] = (\d+);
Replace With :  $1] = getValue($1,$2);
http://stackoverflow.com/questions/26493664/find-replace-multiple-lines-of-code-in-eclipse
You have to make sure the "Regular Expression" is checked in the Search criteria.
When you highlight the item you want to search for, CTRL+H will bring up the search window and if Reg Exp is checked then Eclipse automatically creates a Regular Expression to search for. Then you can replace within your file system.
@Data\R(.|\n)*extends
http://stackoverflow.com/questions/39568716/eclipse-display-view-is-throwing-error
Wrap in curly brackets and press Ctrl+U. Should work in neon.
{throw new NullPointerException();}
JDK8
https://www.eclipse.org/community/eclipse_newsletter/2014/june/article1.php
Convert anonymous class creations to lambda expressions (and back) by invoking the Quick Assists (Ctrl+1):

  • Convert to lambda expression
  • Convert to anonymous class creation

Or invoke Source > Clean Up... to migrate all your existing code to use lambda expressions where applicable: 

http://stackoverflow.com/questions/1914492/block-selection-in-eclipse

Use Ctrl+3 and write "block" in popup.
If you are on a mac you can use option+command+A
Window: Alt+Shift+A
https://dzone.com/articles/eclipses-awesome-block


http://stackoverflow.com/questions/2000078/apache-tomcat-not-showing-in-eclipse-server-runtime-environments
EDIT: With Eclipse 3.7 Indigo Classic, Eclipse Kepler and Luna, the steps are the same (with appropriate update site) but you need both JST Server Adapters and JST Server Adapters Extentions to get the Server Runtime Environment options.

Performance:
http://stackoverflow.com/questions/1631817/annoying-remote-system-explorer-operation-causing-freeze-for-couple-of-seconds
Eclipse -> Preferences -> General -> Startup and Shutdown.
-Uncheck RSE UI.
Eclipse -> Preferences -> Remote Systems.
-Uncheck Re-open Remote Systems view to previous state.

http://stackoverflow.com/questions/21096100/docking-a-detached-view-with-eclipse-kepler
As per njol's answer above, once you have your tab detached (showing as floating outside of your Eclipse IDE), simply click on the tab (not on the title of detached tab window) and drag. Then you will see mouse cursor change showing you where you can drop it to attach the tab to IDE. enter image description here
http://stackoverflow.com/questions/1820908/how-to-turn-off-the-eclipse-code-formatter-for-certain-sections-of-java-code
Eclipse 3.6 allows you to turn off formatting by placing a special comment, like
// @formatter:off
...
// @formatter:on
The on/off features have to be turned "on" in Eclipse preferences: Java>Code Style>Formatter. Click on EditOff/On Tags, enable Enable Off/On tags.

https://www.shortcutworld.com/en/win/Eclipse.html
https://mcuoneclipse.com/2012/04/15/10-best-eclipse-shortcuts/
Ctrl+M — Maximizes the current view or editor. Press Ctrl+M again and it goes back to the previous size.
Ctrl+Shift+/ — Insert block comment,

Ctrl+F7— Switch to next view. Pressing again Ctrl+F7 let you iterate to the next view. Use Ctrl+Shift+F7 for previous view. Shortcut for Window > Navigation > Next View:
Ctrl+Alt+h — Opens the call hierarchy. Shortcut for Navigate > Open Call Hierarchy:
http://www.vogella.com/tutorials/EclipseShortcuts/article.html
 Mac OS uses the Cmd key frequently instead of the Ctrl key.
Quick Access - Ctrl+3 
Ctrl + Shift + RSearch dialog for resources, e.g., text files
Ctrl + Shift + TSearch dialog for Java Types
Ctrl + ESearch dialog to select an editor from the currently open editors
Ctrl + F8Shortcut for switching perspectives
Ctrl + QGo to editor and the position in this editor where the last edit was done

Ctrl + F11Run last launched
Alt + Shift + X, JRun current selected class as Java application
Alt + Shift + TOpens the context-sensitive refactoring menu, e.g., displays
Ctrl+ DDeletes current line in the editor
Ctrl + Shift + OAdjusts the imports statements in the current Java source file
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-cvs-annotate.htm
The Team > Show Annotation action is available from the following places: History View, Repository Explorer, Synchronize View, the Project and Package Explorers, and text editor context menus. The action works in a Quick Diff flavor and offers the following features:
  • Displays the annotations on a local file right in the same editor.
  • Clicking on an annotation or clicking on any line in the editor will prompt the History View to show the corresponding revision information.
  • Doesn't lose your place in the editor when displaying the annotation; simply adds the annotations to the annotation bar of the editor that you are currently using.
  • To turn off annotations, you have to select Revisions > Hide Revision Information from the annotation bar context menu.
Group Breakpoints By
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fviews%2Fbreakpoints%2Fref-groupby_viewaction.htm

https://mcuoneclipse.com/2015/09/03/better-debugging-with-eclipse-step-into-selection/
I would like to step into the outer function FAT1_CheckCardPresence(), but when I do a ‘step-into’, it will first step into the CLS1_GetStdio() function. So there I have to do a ‘step-out’, and if there are multiple inner (nested) function calls, this requires many ‘step-into’ and ‘step-out’ clicks and operations.
I can select or click into the name and use the context menu ‘Step Into Selection’
Or an even better way: I have use CTRL+ALT and click with the mouse (hyperlink mode):

http://www.slideshare.net/eclipsedayindia/eclipse-tips-tricks-39374574
Smart Step into selection
To step into a single method within a series of chained or nested method calls.
Ctrl F5
Ctrl + Alt + Click
Exception Breakpoint: When exceptions are passed over several layers, they are often wrapped or discarded in another exception. To find the origins of an exception, use Exception breakpoint. The execution will suspend whenever the exception is thrown or caught.

Classload Breakpoint: To inspect who is trying to load the class or where is it used for the first time.
Watchpoint: To suspend the execution where a field is accessed or modified.
Method Breakpoint: To suspend the execution when the method is entered or exited.

Scrapebook:
A container for random snippets of code that can be executed any time without a context.
http://blog.deepakazad.com/2010/06/print-points-debugging-by-writing-to.html
  • Printpoints - There are scenarios when the breakpoints fail or are inefficient, in these cases I just use System.out.println(). This is typically when
    • the breakpoint hits too often, for example keypress, focus, mouse events
    • I want to see the order of thread execution
    • I am making some changes and want to see how these changes affect a 'few' variables/expressions, also I am confident that it will take 'a number' of iterations of this change-test process to fix the bug. Printing everything to console in this case proves to be much more efficient than stepping through the code.
Most developers (including me till recently) insert the print statements in their code and the problem with that is that you have to take them out later. I know you can sometimes leave them in the source as tracing statements, but most of the time they have to be taken out. But there is a solution...

The conditional breakpoint editor in Eclipse can be 'tricked' to create what I like to call as Printpoint - and defineas a 'point' in code where the debugger does not 'break' but only 'prints' to console. Essentially a Printpoint is a conditional breakpoint that never suspends execution but only prints to console. To set a printpoint, set a conditional breakpoint with Suspend when 'true' option and a condition which is always false. e.g.
http://eclipsesource.com/blogs/2013/08/13/eclipse-preferences-you-need-to-know/
http://stackoverflow.com/questions/3418665/how-do-i-get-eclipse-to-automatically-add-a-semicolon
"The preference is disabled by default, so you have to enable it. Go to Window > Preferences > Java > Typing. Then enable Semicolons under the section Automatically insert at correct position.
Now when you press semicolon from anywhere in a statement, Eclipse adds a semicolon to the end of the line and places the cursor right after the semicolon so you can start editing the next line."

https://dzone.com/articles/eclipse-spell-checker
Eclipse has a built-in Spell Checker. Go to Window > Preferences > General > Editors > Text Editors > Spelling to enable it.
http://stackoverflow.com/questions/8786880/eclipse-spell-checker
Eclipse in-built spell checker is designed to recognise and only check text. It ignores code such as variable and method names AFAIK

I have founded spell checker from eclipse marketplace. It is JDT spell checker and here is the description
The aim is to provide spelling support for words contained in the names of Java artifacts: Interfaces, Classes, Methods, ... Splitting out the names using regular naming patters for Java names.
Console view
http://stackoverflow.com/questions/888599/eclipse-open-console-apps-in-separate-window
In eclipse, you can have two console views... On the console view, you have a button called 'open console' (the most right button in the console view). If you click this and select option 3 (new console view), you will see two consoles.
If you right click on the console tab and click on 'detached' the console will be detached from the eclipse frame. (for Eclipse Juno, see the HRJ's comment below)
You can select which output you want to see on each console by clicking the 'display selected console' button (second button from the right on the console view)
http://stackoverflow.com/questions/7261151/in-eclipse-can-i-have-multiple-console-views-at-once-each-showing-a-different

  • located near your console tab should be a button "Open Console".
  • If you click this button one of your options should be "New Console View".
Eclipse Screenshot
You'll now have 2 console views.
  • One of your other buttons near your console tab is "Display Selected Console". When you choose this option you can select from any of your running applications.
  • Just select the tab, select which application you want it to watch, and repeat for the other tab.
Window > New Window. 
https://codeyarns.com/2014/11/07/how-to-remove-feature-or-plugin-in-eclipse/
  1. Go to Help -> Installation Details. Click the tab Installed Software.
  2. Choose any of the features or plugins here and click on Uninstall at the bottom-right of this dialog to remove it.
How to hide DS_Store files
https://jonathansblog.co.uk/hide-project-and-ds_store-files-from-eclipse-or-zend-studio-svn
Go to Preferences > Team > Ignored Resources
Click ‘add pattern’
Then add the files you want to ignore.
  1. Right click, Properties
  2. Expand Resources and click onto Resource Filters
  3. Click "Add"
  4. Use these settings
Filter type: Exclude all.
Applies to: Folders
Click "All children (recursive)" as any subfolders containing your pattern will still show up (common case for .git and .svn)
File and folder attributes: Name matches .git
Refactor:
TODO:
http://codingspectator.cs.illinois.edu/compositional-refactoring/
https://github.com/reprogrammer/composite-refactorings
http://help.eclipse.org/mars/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-menu-refactor.htm
Introduce FactoryCreates a new factory method, which will call a selected constructor and return the created object. All references to the constructor will be replaced by calls to the new factory method.
Available:Constructor declarations
Introduce ParameterReplaces an expression with a reference to a new method parameter, and updates all callers of the method to pass the expression as the value of that parameter.
Available:Text selections that resolve to expressions
Encapsulate FieldReplaces all references to a field with getter and setter methods.
Available:Field or a text selection resolving to a field.
This refactoring is also available as quick assist on field declarations and references selected in the editor.
Generalize Declared TypeAllows the user to choose a supertype of the reference's current type. If the reference can be safely changed to the new type, it is.
Available:Type references and declarations of fields, local variables, and parameters with reference types
http://www.drdobbs.com/refactoring-with-eclipse/184405857?pgno=1
https://bmwieczorek.wordpress.com/2009/11/28/eclipse-refactoring/
http://stackoverflow.com/questions/3263110/difference-between-introduce-parameter-and-change-method-signature-in-eclipse
Introduce parameter lets you convert a local expression to a parameter of the current method that will be added to the end of the parameter's list.
Change method signature allows you to introduce parameters without any special relation to your method's body, reorder or modify existing parameters.

eclipse refactoring: move multiple static methods and/or fields
http://stackoverflow.com/questions/19247915/eclipse-refactoring-move-multiple-static-methods-and-or-fields
Expand until you see the static methods or varibles. Select all that you want to move. Right click. Select Refactor. Then choose the class where you want to move. Click OK. That will not just copy and paste but will refactor (update references to those methods and variables).
How to pass the -D System properties while testing on Eclipse?

Run -> Run configurations, select project, second tab: “Arguments”. Top box is for your program, bottom box is for VM arguments, e.g. -Dkey=value.
-DincludeConditionalTests=true

When eclipse crashes, sometimes, it will uncheck Project -> "Build automatically".
Then when you run server -> deploy, it will fail.

http://www.slideshare.net/sbegaudeau/10-effortless-tricks-to-speed-up-your-java-development-in-eclipse
The name of your variables is automatically computed for you
Use camel case to select quickly the method to call among all the methods available

Quick fix:
Assign the result of a method to a new local variable
Let Eclipse create local variables, choose their name and realize the necessary import
Initialize local variables

Scrapbook Page
Test your code without having to run your complete application

Open TypeCtrl + Shift +T
Find the type that you were looking for and filter the result with camel case - not really useful
https://recoveringprogrammer.wordpress.com/2013/04/06/using-eclipse-scrapbook-to-quickly-test-your-code/

http://www.eclipseonetips.com/2010/02/01/generate-static-imports-in-eclipse-on-autocomplete/
  1. Go to Window > Preferences > Java > Editor > Content Assist > Favorites.
  2. Click New Type. This brings up a dialog where you can enter the fully qualified type.
  3. Enter org.junit.Assert and click Ok (you could also use the Browse… if you want to search for the type). Eclipse will add an entry to the list which reads org.junit.Assert.*.
  4. Click Ok on the preferences dialog to save and close the preferences.
Here’s what my list currently looks like:
You can add an entry for any other static import you’d like, even for a static Utils class you’ve written yourself.
Now, to test that it works you can add a JUnit test, type assertEquals, press Ctrl+Space and press Enter on the appropriate entry. Eclipse will now add the static import org.junit.Assert.assertEquals (ororg.junit.Assert.*, depending on your Organize Imports preferences).
http://stackoverflow.com/questions/288861/eclipse-optimize-imports-to-include-static-imports
Window > Preferences > Java > Editor > Content Assist > Favorites
In mine, I have the following entries (when adding, use "New Type" and omit the .*):
org.hamcrest.Matchers.*
org.hamcrest.CoreMatchers.*
org.junit.*
org.junit.Assert.*
org.junit.Assume.*
org.junit.matchers.JUnitMatchers.*
All but the third of those are static imports. By having those as favorites, if I type "assertT" and hit Ctrl+Space, Eclipse offers up assertThat as a suggestion, and if I pick it, it will add the proper static import to the file.
If you highlight the method Assert.assertEquals(val1, val2) and hit Ctrl + Shift + M (Add Import), it will add it as a static import, at least in Eclipse 3.4.
Just highlight or select TimeUnit.SECONDS and type Ctrl+Shift+M or choose Menu option Add import to static import this static variable from java.util.TimeUnit class.

cmd-shift-M on the mac 
http://stackoverflow.com/questions/7322705/finding-import-static-statements-for-mockito-constructs

import static org.mockito.Mockito.*;
import static org.mockito.Matchers.*;
https://eclipse-top-features.zeef.com/arjan.tijms
Code Recommender
http://eclipsesource.com/blogs/2012/06/26/code-recommenders-top-eclipse-juno-feature-2/
http://www.beyondjava.net/blog/eclipse-code-recommenders/
A particularly nice feature is subword completion. Sometimes you don’t know a method name precisely, but you know a part of it – and not necessarily the beginning. In the case, the autocompletion of Eclipse Mars still finds the method:
http://www.codetrails.com/blog/code-recommenders-2-2-eclipse-mars
Constructor Completion
Subtypes Completion
Code Recommenders is now enabled by default

http://eclipsesource.com/blogs/2014/06/20/snip-match-top-eclipse-luna-feature-4/?utm_medium=referral&utm_source=zeef.com&utm_campaign=ZEEF
There is also a snippets view that shows all the available templates.
By default, the snippets are fetched from a GitRepository (configured in Preferences -> Code Recommenders -> SnipMatch). Of course, you could fork this repository and modify it as you see fit.
Finally, SnipMatch allows you to edit or even add your own snippets using the JFace template language.
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fviews%2Fshared%2Fref-forcereturn.htm
Force Return
Select the Force Return command to return from the current method with the specified value.

to-do: seems not work
http://stackoverflow.com/questions/9580642/how-to-disable-automatically-build-for-only-one-project
I notice that if you disable "build automatically" under the "project" menu, you can then select which working sets to include in your build (project -> build working set -> select working set). I don't think this is the "automatic" build behavior you are looking for though.... also, for the problems view, I thought this stack overflow answer was pretty solid.
@RunWith(ClasspathSuite.class)
public class RunAllTests {
}

http://stackoverflow.com/questions/25075617/eclipse-luna-debug-slow-only-up-to-the-very-first-breakpoint
I found this post trying solve my issue: Very very slow to initialize tomcat, hibernate, etc. If you fall down here for similar problem I would suggest you what resolved to me. Try:
  • Clear all breakpoints, mainly those in API's, clear expressions too.
Starting Eclipse with "-consolelog -debug"

How to set a breakpoint on a default Java constructor in Eclipse?
If the code where you want to set a breakpoint in, is on the build path and not in your project itself, then if you open the outline view, you'll see that the default constructor is present there, and you can right-click on it and choose "Toggle Method Breakpoint". 


Solution 1: member initializers

Solution 2: class load breakpoints
Howto prevent eclipse from line wrapping in XML and HTML files?
Preferences > XML > XML Files > Editor, and set line-width there (Do accordingly for HTML, under Web > HTML files)
I just found out that Eclipse won't format that bit if I enclose the text between <![CDATA[..]]>. For instance:
<pattern><![CDATA[%d{HH:mm:ss.SSS} [%thread] [%X{host}|%X{ip}|%X{user}] %-5level %logger{36} - %msg%n]]></pattern>
https://marketplace.eclipse.org/content/grep-console
Grep Console allows you to define a series of regular expressions which will be tested against the console output. - See more at: https://marketplace.eclipse.org/content/grep-console#sthash.SuFOKGxa.dpuf

Shortcuts:
http://www.daveoncode.com/2009/08/25/eclipse-shortcut-switch-convert-uppercase-text-cod-lowercase/
Upper case: CTRL+SHIFT+Y (CMD+SHIFT+Y on Mac OS X)
Lower case: CTRL+SHIFT+X (CMD+SHIFT+X on Mac OS X)
Don't forget Ctrl+Shift+L, which displays a list of all the keyboard shortcut combinations (just in case you forget any of those listed here).

Debugging Skills
Force Return
http://stackoverflow.com/questions/11531249/can-i-force-return-from-a-void-method-in-the-eclipse-debugger
Yes, you can do this, don't use the context menu in the Variable display, but right-click in your code and you will see "Force Return" in the context menu.

http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fviews%2Fshared%2Fref-forcereturn.htm
From the Display View, we could enter the value we want returned, select it and use the Force Return command to force the method isEmpty() to return with that value (in the following example we will force isEmpty() to return with the value true).
Select the Uncaught locations option to suspend execution when an exception of the same type as the breakpoint is thrown in an uncaught location.
In the Eclipse preferences, you can uncheck the option Suspend execution on uncaught exceptions, located in Java > Debug panel.
You can fix this immediately by opening the Markers view and delete the Java Exception Breakpoints.
Markers view with Java Exception Breakpoints
However, to permanently remove this type of breakpoints, you have to go to the Java Debug options and uncheck the "Suspend excecution on uncaught exceptions" option. Then this type of breakpoints won't get added again in the future.
Java Debug options in Eclipse


This is because the Eclipse project is not properly configured.
  1. eclipse preference -> junit -> Add -ea checkbox enable.
  2. right click on the eclipse project -> run as -> run configure -> arguments tab -> add the -eaoption in vm arguments
Convert string concatenations into StringBuilder or MessageFormat calls with Eclipse’s Quick Fix


toString() Generator: Code Styles - Use StringBuilder or Skip Null


entering just literal strings doesn't work. To get a line to be colored, you have to enclose the string in .* on either side, like so: .*ERROR.*




Seems You have to recompile class - so findbugs can work.

Infinitest is a Continuous Testing plugin for Eclipse and IntelliJ.

You can perform JUnit tests across multiple projects using Classpath Suite. In general all you need to do is:
  1. Create an Eclipse project depending on all the projects you want to test.
  2. Write a suite:
    @RunWith(ClasspathSuite.class)
    public class MySuite
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.takari.junit</groupId>
<artifactId>takari-cpsuite</artifactId>
<version>1.2.7</version>
</dependency>


Debugging
http://ubuntuforums.org/showthread.php?t=793574
Go to Window >> preferences.. >> Java >> Debug >> Detail Formatters
Set "Show wariable details (toString() value)" to "As the label for variables with detail formatters".
Now go and debug some code with StringBuilder, right click the StringBuilder variable and click "New Detail Formatter..", in the code snippet area add "this.toString();" or just "this".

https://blog.codecentric.de/en/2013/04/again-10-tips-on-java-debugging-with-eclipse/

– Display View

To execute your code, just mark it and use the context-menu or CTRL+U (execute) or CTRL+SHIFT+I (inspect).

– Navigation: Drop to Frame

– Navigation: Step into Selection

“Run to line” is also a nice feature. Just place your cursor in front of the line where you want to stop and hit “CTRL+R”.

– Human Readable Objects

The Variables View is using the toString-Method of your objects to display the value. Because of this it is very, very helpful
to provide good toString-implementations. 
it might be an option to create an “Detail Formatter” in Eclipse. To do that, you have to right click an object in the variables view and click on “New Detail Formatter…”. Then you can provide some code to display this type of Object in the future.
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fviews%2Fshared%2Fref-detailpane.htm

Assign Value
Assigns a new value to the currently selected variable by evaluating the text in the detail pane.

Select Columns...
Allows you to select which columns are shown when columns are visible. Variables View only.

The eclipse quick search plugin is part of Spring Tools Suite (STS).
 Now press the command CTRL + SHIFT + L to open the quick search editor.

Recently discovered the following plugin has beta support for searching into linked source jars:https://github.com/ajermakovics/eclipse-instasearch
You have to enable searching source jars in the preferences as it is turned off by default. Depending on how much source you have, the indexing process is very slow, but then search is very fast.

How to search for a class/package in a set of JAR files?

Provided that you are using the JAR files in a project as a library, then you can use the powerful Java search. Here's for example how to find where the org.apache.cxf.Bus class is contained :

Search code:
com.sun.jersey.config.feature.DisableWADL site:grepcode.com
You open the dialog by pressing CTRL+SHIFT+L (or CMD+SHIFT+L on Mac):

Optimizer for Eclipse

EASE
loadModule('/System/Resources') for iproject in getWorkspace.getProjects: if not iproject.isOpen: continue ifile = iproject.getFile("README.md") if not ifile.exists: contents = "# " + iproject.getName + "\n\n" if iproject.hasNature("org.eclipse.jdt.core.javanature"): contents += "A Java Project\n" elif iproject.hasNature("org.python.pydev.pythonNature"): contents += "A Python Project\n" writeFile(ifile, contents)

def save_dirty_editors: workbench = getService(org.eclipse.ui.IWorkbench) for window in workbench.getWorkbenchWindows: for page in window.getPages: for editor_ref in page.getEditorReferences: part = editor_ref.getPart(False) if part and part.isDirty: print "Auto-Saving", part.getTitle part.doSave(None)

在运行脚本之前,你需要勾选 ‘Allow Scripts to run code in UI thread’ 设定,这个设定在 Window > Preferences > Scripting 中。然后添加该脚本到工作空间,右击并选择“Run as > EASE Script”。每次编辑器自动保存时,控制台就会输出一个保存的信息。要关掉自动保存脚本,只需要点击控制台的红色方块的停止按钮即可。
# name : Explore from here # popup : enableFor(org.eclipse.core.resources.IResource) # description : Start a file browser using current selection loadModule("/System/Platform") loadModule('/System/UI') selection = getSelection if isinstance(selection, org.eclipse.jface.viewers.IStructuredSelection): selection = selection.getFirstElement if not isinstance(selection, org.eclipse.core.resources.IResource): selection = adapt(selection, org.eclipse.core.resources.IResource) if isinstance(selection, org.eclipse.core.resources.IFile): selection = selection.getParent if isinstance(selection, org.eclipse.core.resources.IContainer): runProcess("explorer.exe", [selection.getLocation().toFile().toString()])


  1. Move the cursor to the method call
  2. Press Ctrl + T
  3. Select your desired implementation
  4. Hit Enter

当我第一次找到强大的插件时,我非常高兴。我安装的越来越多后,eclipse就用起来不舒服了。所以你可以从众多的插件中禁用一些不常用的插件,禁用不代表删除,你仍然可以启用他们。
Help -> About Eclipse SDK -> Instalation Details -> <Select plugin> -> Uninstall
动画很酷,但如果可以的话,我总是在所有的工具中禁用动画。所以classic主题是我最常用的主题。
Java Window -> Preferences -> General -> Appearance -> Uncheck 'Enable animations' 1 Window -> Preferences -> General -> Appearance -> Uncheck 'Enable animations'

禁用label decoration

label decoration是项目、文件、类层级上的小图标,它可以有益于显性化文件的状态。比如:文件是否已经提交到git。很多插件都提供了这个功能,但很少有用。你可以仅留下你想要的,其他的禁用。
Window -> Preferences -> General -> Appearance -> Label Decorations


有时在性能较差的机器上,或者当你有很多类的时,自动补全功能性能就会很差。一个很小的优化是减少自动补全的proposal。我仅保留了Java Proposals和Template Proposals:


关闭不相关的工程

如果你仅开发部分eclipse中的工程,那你最好把其他功能关闭掉。他们不会出现在eclipse索引中。你可以在workspace中手动关闭不相关的工程(Close unrelated projects)。但我推荐使用Working Set,你可以添加多个工程到一个Working Set中,这样就可以快速的在Working Set件切换。
Right Click on Project -> Assign Working Sets..

关闭编辑器中不用的tab

编辑中太多的tab会导致eclipse性能下降,可以这样控制下tab的个数:
Window -> Preferences -> General -> Editors
勾选 Close editors automatically 并设置 Number of opened tabs 为10。

为了逼着自己使用所有的快捷键,我直接把工具栏给禁用了。
Window -&gt; Hide Toolbar

禁用拼写检查
你还是个程序员吗?我觉得没有任何理由需要拼写检查功能。取消这个功能吧:
Window -> Preferences -> General -> Editors -> Text Editors -> Spelling -> Uncheck 'Enable spell checking'

4.6 new features


https://www.eclipse.org/eclipse/news/4.6/platform.php
Toggle Word Wrap button has been added to the workbench toolbar. Shortcut: Alt+Shift+Y.
In text editors, you can now use Zoom In (Ctrl++ or Ctrl+=) and Zoom Out (Ctrl+-) commands to increase and decrease the font size.
The Search > File... dialog has a new option to search in binary files as well.

Terminate and Relaunch option is now available while launching from history. The default setting is to launch without terminating previous launches. To enable automatic termination, select the option "Terminate and Relaunch while launching from history" on Preferences > Run/Debug > Launching.
The behavior not selected on the preference page can also be activated on-demand by holding the Shift key while launching the configuration from history.
You can use the Toggle visibility of the window toolbars command (via Quick Access: Ctrl+3) to hide all currently visible toolbars of the current window. E

On the Mac, Window > Toggle Full Screen (Control+Command+F) still works as before.

You can disable the CSS-based styling of the Eclipse IDE via Preferences > General > Appearance > Enable theming. This will prevent Eclipse from rendering custom colors, shades, and borders, and may result in better performance.

Content Assist now supports substring patterns. Enter any part of the desired proposal's text, and Content Assist will find it! For example, completing on selection proposes all results containing selection as a substring.

The Java editor now offers default templates for creating "== null" and "!= null" checks.
The Refactor > Rename popup now shows an Options... link which opens the full Rename dialog that provides more options like renaming a field's getter and setter methods.
Create new fields from method parameters
You can now assign all parameters of a method or constructor to new fields at once using a new Quick Assist (Ctrl+1):
You can now select multiple elements in views like Package Explorer and Outline and then search for References, Declarations, Implementors, and Read/Write Access (where applicable):

Quick Fix to configure problem severity
You can now configure the severity of a compiler problem by invoking the new Quick Fix (Ctrl+1) which opens the Java > Compiler > Errors/Warnings preference page and highlights the configurable problem.
Quick Fix to add @NonNull to local variable
To always install all enabled breakpoints, you can disable the new option Preferences > Java > Debug > Do not install breakpoints from unrelated projects
http://www.howtogeek.com/171432/ram-disks-explained-what-they-are-and-why-you-probably-shouldnt-use-one/
RAM disks take advantage of this, using your computer’s RAM as a lightning-fast virtual drive

RAM is volatile memory. When your computer loses power, the contents of your RAM will be erased. This means that you can’t store anything important on a RAM disk — if your computer crashed because of lost power, you’d lose all the data in your RAM disk. So saving files to the RAM disk is pointless unless you don’t care that you’d lose the files

Because RAM isn’t persistent, you’d also have to save the contents of your RAM disk to disk when you shut down your computer and load them when you turn it on.
When you turn on your computer, the RAM disk program would have to read the RAM disk image from your hard drive and load it back into RAM. In other words, you’re simply getting faster program-load times at the expense of longer boot-up times.
https://coffeeorientedprogramming.com/2016/09/02/ramdisk-for-faster-compilation/
sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs -o size=2G tmpfs /mnt/ramdisk
http://www.whizu.org/articles/how-to-install-eclipse-on-a-ramdrive.whizu
 Go to Window > Preferences > General and check the “Show heap status” option.
http://www.whizu.org/articles/how-to-install-the-jdk-on-a-ramdrive.whizu

http://www.jhack.it/wiki/Eclipse
http://stackoverflow.com/questions/7677127/purpose-of-the-build-automatically-option-in-eclipse
Project - Disable Autobuild option does not always mean autobuild is off. For example "Makegood" test automation plugin will trigger autobuild when Preferences - Run/Debug - launching - (General opt) Build before launch is ON. So turn it off if manual build needed.
Word wrap
https://bugs.eclipse.org/bugs/show_bug.cgi?id=22927
On Variables/Expressions view,  we can right click to enable word wrap text

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts