3
votes

I am trying to create a project in eclipse from an existing ant build.xml file. I receive a list of javac tasks found and directed to select a single javac task to continue. How do I process the javac tasks?

1
Once it's imported - you should just be able to right click the build.xml, then under "Run As", select the first "ant build" option - JGlass
Thanks do you import after you build the project or before? - PaulLawn
Do you import the file structure or the jars? As you can tell I am a neophyte. - PaulLawn
Its okay on the neophyte part, everyone has to start somewhere! When you import an existing ant project into eclipse - everything would already be there for eclipse and your project as it would already be contained in the existing project - jars, resources, etc. When you build it you should get any errors. If you add new jars or functionality, you'll need to modify the ant script to use those jars/resources. Is the projects something you got from github? - JGlass
No, the project is not from jithub. I do not think I am importing an existing ant project. I think I am creating a project using and ant.xml file. Is this wrong? I have source code and I am expecting to have to compile some of the source. Using these new jar files I expect to compile more code until all files are compiled and are in jar files. - PaulLawn

1 Answers

2
votes

I wouldnt recommend going the Ant route at this stage as it complicates things. Maven would be the way to go in the end, or Gradle - but that's way out of the scope at this point. Eclipse doesn't need ant or a build.xml ant related file!

In Eclipse do the following

  1. Create a new Java Project if you're using plain old Java, if you plan on using J2EE, then create a new Java EE, EAR project in which you would then create and add optionally a new EJB or WAR ((WEB)Dynamic Web Project). But an EJB or WAR project does not have to reside within a EAR and an EAR only will work at the moment with a J2EE Application server like JBoss, WebSphere or GlassFish
  2. Once the projects created, copy your java source code to the "src" directory that was created by eclipse - you can right click the src folder in eclipse, select properties, then resources and it will tell you the path to it.
  3. If your project requires supporting libraries/packages (jars) then the easiest thing to do though not totally recommended is to create a "lib" folder and place it in either the EAR projects parent directory, the EJB projects parent directory, or the WAR projects parent directory if you're doing J2EE, if you're just doing plain old java, then create the lib folder at the same directory level as the "src" directory. Put your jars in there.
  4. Eclipse wont immediately find those jars so:
  5. Right click the project in eclipse select properties
  6. Select java build path in left pane
  7. Click the libraries tab
  8. Click the add external jars button
  9. Navigate/browse to the "lib" folder and select all the jars
  10. Click Apply/Okay
  11. Eclipse should build automatically (on any change), but if not click the Project menu and click build automatically. Sometimes you might also have to clean, which then rebuilds

This should be the basic steps on getting a minimal Java or J2EE eclipse project started. Let me know in comments to this answer and I can modify it if need be to more correctly reflect what you're doing