how to run Eclipse -clean on a Mac?

JavaEclipse

Java Problem Overview


I can run eclipse -clean on my PC, but on my Mac, the executable is Eclipse.app -- how do you run that with arguments on the command-line?

Java Solutions


Solution 1 - Java

If you CD to the eclipse installation directory using terminal, then you will see there is a directory called eclipse.app. CD to Eclipse.app\Contents\MacOS under that directory there should be an executable called eclipse.

I believe you can launch eclipse from the commandline by executing the eclipse executable with the -clean argument, as below:

> ./eclipse -clean

Solution 2 - Java

Quote: "On Mac OS X, you start Eclipse by double clicking the Eclipse application. If you need to pass arguments to Eclipse, you'll have to edit the eclipse.ini file inside the Eclipse application bundle: select the Eclipse application bundle icon while holding down the Control Key. This will present you with a popup menu. Select "Show Package Contents" in the popup menu. Locate eclipse.ini file in the Contents/MacOS sub-folder and open it with your favorite text editor to edit the command line options."

Find more here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Frunning_eclipse.htm

Solution 3 - Java

Here is a script using macports to automate the restart. You can put this script e.g. on your desktop to be able to double click it.

#!/bin/bash
# WF 2014-03-14
# start Eclipse cleanly
pgrep -fl Eclipse.app
if [ $? -eq 0 ]
then
  echo "Eclipse is running - shall i kill and restart it with -clean? y/n?"
  read answer
  case $answer in
    y|Y) ;;
    *) echo "ok - I'm aborting this ..."
    exit 1;
    ;;
  esac
  echo "killing current eclipse"
  pkill -f Eclipse.app
fi
echo "starting eclipse cleanly ..."
/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -clean -clearPersistedState&

Solution 4 - Java

I had this problem earlier today. When I would try to run clean option it still wouldn't finish building the workspace. I found that if I removed the .metadata file from the workspace it would create a brand new workspace and even launch the initial welcome screen. Warning this will remove all of your builds, and all information from your workspace in eclipse, however it will remain intact in your finder folder which you can later import from with a little finagling.

Solution 5 - Java

Geesh everyone. If you have a path to it, great, the command line works as above. Otherwise, navigate to the enclosing folder of your Eclipse, then into Eclipse.app and execute the following:

./eclipse -clean -vmargs -XstartOnFirstThread

This will not let your command window exit gracefully so you'll have to kill the command window after doing it.

(But to be sure, clean doesn't always work.)

EDIT: I should have edited this the next day! It blew out my workspaces - primarily because of the shared commands. All sorts of Errors.

What I did to resolve (instead of a reinstall): I restored a backup of the entire Eclipse Directory from a few days before and refreshed the projects. It took some doing. Not pretty.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJason SView Question on Stackoverflow
Solution 1 - JavaAlvinView Answer on Stackoverflow
Solution 2 - JavamkroView Answer on Stackoverflow
Solution 3 - JavaWolfgang FahlView Answer on Stackoverflow
Solution 4 - JavadaveluptView Answer on Stackoverflow
Solution 5 - JavaJohn StackView Answer on Stackoverflow