简体   繁体   中英

How to configure/Run an Ant Java project in Eclipse

I have a working java project (in ubuntu 12.04LTS, configured and compiled using ant). Is there a way I can configure and run it in Eclipse? Every time I try to load it in eclipse it gives a bunch of errors because of packages not being where its expecting I guess. Also, it will help if you could tell whats build path. I'm using Eclipse Java EE IDE Kepler Release. My project structure looks like this:

project
  build.xml
  build.properties
  build.common
  projFolder - proj code, 3rd party lib/bin/src, 
  commons - proj code, ui code, 3rd party lib and binaries
  dist - has a bunch of scripts and jars and may be some binaries

And how I got my project in Eclipse (this is probably not the most efficient way to have the project running in Eclipse, not sure) I did new->java project then enter project name, unchecked 'use default location' and provided the location of my project so it imported my project in eclipse. then in my classes i have all the errors (red cross at the display) and it says imports cannot be resolved, objects can't be resolved to a type and such.

import com.psid.codedata.projects.TProjectDRD; import com.psid.codedata.projects.TProjectsDRD;

error on above imports: The import cannot be resolved

It probably needs you to add all your source folders to the build path:

  1. Right-click on your project and select Properties,
  2. Along the left-hand side click "Java Build Path",
  3. Click the "Source" tab if it isn't already selected,
  4. Click the "Add Folder..." button on the right-hand side,
  5. Select whatever your source folders are in projFolder and commons ,
  6. Click the "Libraries" tab,
  7. Click the "Add JARs..." button on the right-hand side,
  8. Select whatever your libraries are in projFolder , commons and dist ,
  9. Click the "OK" button.

Note that "New -> Java project" is for creating a brand new, empty project. Since you want to create an Eclipse project from an existing project with an Ant script, you should select the appropriate selection under the "Ant" subsection in the New Project dialog. See this answer to a related SO question for details.

add this line to nbproject/project.properties:

j2ee.server.home= http://localhost

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM