Eclipse Can’t Find the Main Class

Recently I experienced two such annoyances and each took me quite a while to figure out, so here I jot them down.

Case#1: Crashed Eclipse metadata. This can happen after unexpected power outage or other ungraceful Eclipse closure.

  • Symptom: Eclipse can’t find project or main class
  • Solution: Find out the current workpace (Preference->search for Workspace), shutdown Eclipse, delete the .metadata directory under the workspace directory, start Eclipse, create the project and run it again

Case#2: Wrong VM options (VM arguments).

  • Symptom: error message in console tab like “Error: Could not find or load main class Files.Liuzy163.HelloWorld.lib”
  • Cause: I put a -DlibDir=c:\Program Files\Liuzy163\HelloWorld\lib as a VM argument.
  • Solution: double quote the arguments including spaces.
Advertisements
This entry was posted in Java, Tool and Debug and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s