Explain Codes LogoExplain Codes Logo

How to run eclipse in clean mode? What happens if we do so?

java
prompt-engineering
best-practices
tools
Alex KataevbyAlex Kataev·Feb 20, 2025
TLDR

To start Eclipse in clean mode, apply the -clean flag when launching Eclipse:

eclipse -clean

This operation refreshes the plug-in state and often resolves startup issues by clearing the cached data. Note that this may result in longer startup times due to required system reconfigurations.

Breaking down the '-clean' command

Utilizing the -clean argument with Eclipse does the following:

  1. Clears the OSGi bundle cache: Under the hood, Eclipse uses the OSGi framework for its modularity. Cached states of each module help speed start-up time. With the -clean flag, this cache gets cleared, forcing the system to re-evaluate dependencies at startup.
  2. Resolves plug-in discrepancies: If plugins have been manually installed or removed, the -clean argument ensures that these changes are properly ingested by the system.
  3. Preserves workspace data: Worry not, your workspace data, including project settings and configurations, remains untouched. It's only the system settings that get a reset.

Making '-clean' a habit

Here are a few tips to seamlessly use clean mode in your Eclipse ventures:

Automating with scripts

You can save the hassle of manually typing eclipse -clean every time by automating the process. This can be done by creating batch scripts (for Windows) or shell scripts (for UNIX-like systems). Here's a simple example for Windows:

@echo off echo "Time for some spring cleaning!" start eclipse -clean echo "Voila! Time for some clean code, literally."

Running this script would start Eclipse in clean mode, saving you a handful of keystrokes. Remember to replace eclipse with your specific eclipse executable path if required.

Modifying eclipse.ini or shortcuts

If you don't want to bear the additional startup time every time you open Eclipse, you can specify the -clean argument in either the eclipse.ini file or the shortcut you use to open Eclipse. But remember to remove it once your issues are solved.

Ideal scenarios for clean mode

Here are some situations where running Eclipse in clean mode might just be the trick to resolving your quandaries:

  • When you perform upgrades or downgrades of the Eclipse environment.
  • Encounter unexplained errors, especially revolving around plugins or dependencies.
  • If any new plugins, installed by you, aren't behaving as expected.

Exploring advanced usage options

While -clean can solve quite a few problems, frequent use might make your InitJVM time feel like forever. It's best used only when required. However, there are other command-line options that can enhance your productivity:

Some more useful options

Here are some other command line options that you can use with Eclipse for more targeted troubleshooting or performance enhancements:

  • -debug: Launches Eclipse in debug mode. Extremely useful when hunting down those pesky bugs.
  • -refresh: Refreshes the workspace on startup. All Eclipse, none of the piled-up old changes.
  • -showLocation: Displays the workspace location on the title bar. A lifesaver if you are one of those folks dealing with multiple workspaces.