Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Java Development User Guide
Previous Page Home Next Page

Quick Fix

The Java editor offers corrections to problems found while typing and after compiling. To show that correction proposals are available for a problem or warning, a 'light bulb' is visible on the editor's annotation bar.

Left click on the light bulb or invoking Ctrl+1 (Edit > Quick Fix) brings up the proposals for the problem at the cursor position.
Each quick fix shows a preview when selected in the proposal window.

Quick fix selection dialog

Some selected quick fixes can also be assigned with direct shortcuts. You can configure these shortcuts on the Opens keys preference page General > Keys preference page (in the 'Source' category).

Some quick fixes offer to fix all problems of the same kind in the current file at once. The information text in proposal window contains this information for all applicable proposals. To fix all problems of the same kind, press Ctrl + Enter.

The following quick fixes are available:

Package Declaration
  • Add missing package declaration or correct package declaration
  • Move compilation unit to package that corresponds to the package declaration
  • Remove unused, unresolvable or non-visible import
  • Invoke 'Organize imports' on problems in imports
  • Create new class, interface, enum, annotation or type variable for references to types that can not be resolved
  • Change visibility for types that are accessed but not visible
  • Rename to a similar type for references to types that can not be resolved
  • Add import statement for types that can not be resolved but exist in the project
  • Add explicit import statement for ambiguous type references (two import-on-demands for the same type)
  • If the type name is not matching with the compilation unit name either rename the type or rename the compilation unit
  • Remove unused private types
  • Add missing type annotation attributes
  • Create new constructor for references to constructors that can not be resolved (this, super or new class creation)
  • Reorder, add or remove arguments for constructor references that mismatch parameters
  • Change method with constructor name to constructor (remove return type)
  • Change visibility for constructors that are accessed but not visible
  • Remove unused private constructor
  • Create constructor when super call of the implicit default constructor is undefined, not visible or throws an exception
  • If type contains unimplemented methods, change type modifier to 'abstract' or add the method to implement
  • Create new method for references to methods that can not be resolved
  • Rename to a similar method for references to methods that can not be resolved
  • Reorder or remove arguments for method references that mismatch parameters
  • Correct access (visibility, static) of referenced methods
  • Remove unused private methods
  • Correct return type for methods that have a missing return type or where the return type does not match the return statement
  • Add return statement if missing
  • For non-abstract methods with no body change to 'abstract' or add body
  • For an abstract method in a non-abstract type remove abstract modifier of the method or make type abstract
  • For an abstract/native method with body remove the abstract or native modifier or remove body
  • Change method access to 'static' if method is invoked inside a constructor invocation (super, this)
  • Change method access to default access to avoid emulated method access
  • Add 'synchronized' modifier
  • Override hashCode()
  • Open the 'Generate hashCode() and equals()' wizard
Fields and variables
  • Correct access (visibility, static) of referenced fields
  • Create new fields, parameters, local variables or constants for references to variables that can not be resolved
  • Rename to a variable with similar name for references that can not be resolved
  • Remove unused private fields
  • Correct non-static access of static fields
  • Add 'final' modifier to local variables accessed in outer types
  • Change field access to default access to avoid emulated method access
  • Change local variable type to fix a type mismatch
  • Initialize a variable that has not been initialized
  • Create getter and setters for invisible or unused fields
Exception Handling
  • Remove unneeded catch block
  • Handle uncaught exception by surrounding with try/catch or adding catch block to a surrounding try block
  • Handle uncaught exception by adding a throw declaration to the parent method or by generalize an existing throw declaration
Build Path Problems
  • Add a missing JAR or library for an unresolvable type
  • Open the build path dialog for access restriction problems or missing binary classes.
  • Change project compliance and JRE to 1.5
  • Change workspace compliance and JRE to 1.5
  • Add cast or change cast to fix type mismatches
  • Let a type implement an interface to fix type mismatches
  • Add type arguments to raw references
  • Complete switch statements over enums
  • Remove dead code
  • Insert '//$FALL-THROUGH$'
  • Insert null check
  • For non-NLS strings open the NLS wizard or mark as non-NLS
  • Add missing @Override, @Deprecated annotations
  • Add missing Javadoc comments
  • Add missing Javadoc tags
  • Suppress a warning using @SuppressWarnings

Quick Assists are proposals available even if there is no problem or warning. See the Quick Assist page for more information.

Related concepts

Java editor
Quick fix and assist

Related reference

Quick Assist
JDT actions

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire