Create a eclipse project using existing ant build.xml file

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?


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

  • 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
  • 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.
  • 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.
  • Eclipse wont immediately find those jars so:
  • Right click the project in eclipse select properties
  • Select java build path in left pane
  • Click the libraries tab
  • Click the add external jars button
  • Navigate/browse to the "lib" folder and select all the jars
  • Click Apply/Okay
  • 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

    链接地址: http://www.djcxy.com/p/44386.html

    上一篇: 使用包含build.xml文件的ant创建一个可执行的jar文件

    下一篇: 使用现有的ant build.xml文件创建一个eclipse项目