Devolus
Devolus

Reputation: 22094

How to execute java source in Eclipse

I have a java sourcetree with eclipse projects. When I originally created them, everything works fine. The problem is that I had to switch machine and could only copy the whole working source tree to the new machine. Now when I try to execute my projects in Eclipse it doesn't work, because Eclipse apparently doesn't accept a sourcefile as the main entry point.

The problem is as follows:

The package path looks like this:

package a.b.c.d.project;

Now when I import the project via the New Project and specify the path, then it uses the path of the project which is on a lower level and I get an error that the package is wrong. When I import the whole sourcetree as a single project, the package path is correct, but then I can't launch the source. When I try to create a run configuration Eclipse claims it doesn't find any sources with main and the dialog box stays empty even though the sources are there and contain a main.

So what is the exact procedure to tell Eclipse to execute my Java files?

Update

An example from a source looks like this:

package net.arcor.sls.HibernateDB.helper.hibernate_database_record;
import ...
public class HibernateDatabaseRecord
...

and the error message is:

The declared package "net.arcor.sls.HibernateDB.helper.hibernate_database_record" does not match the expected package "helper.hibernate_database_record"

So apparently it now ignores that full package path because it set the projects directory as the package base. Since these projects were initially created as subprojects under the "net.arcor.sls" project I somehow need to reset the path.

Upvotes: 2

Views: 236

Answers (1)

Mahdi
Mahdi

Reputation: 768

The steps required to start working with a new Eclipse:

  1. Copy project Source to workspace belong to new eclipse
  2. Open eclipse And right click on Project Explorer and click import
  3. In pop up click import ... and in General folder click Existing Project into Workspace
  4. In new window Browse project source folder in workspace
  5. If there is no notification top of the window, click finish

Upvotes: 1

Related Questions