Java Preprocessor Using Eclipse Part 3 PDF Print E-mail
Written by Administrator   
Sunday, 03 January 2010 16:22

Java Preprocessor Using Eclipse Part 3

<-- Prev Page          Next Page -->


 Step 3: Create a build.xml file in your Java project

 By default, Eclipse builds your Java projects for you.    To use the preprocessor, you can instead create an XML file in your project that will direct Ant to do the building of your Java project.    The nice thing about using Ant build file is that it can be configured to not only compile the source, but also create the final output jar, run Javadoc to automatically generate Javadoc, or anything else you'd like to do.

   I learned how to make an Ant build file from Lars Vogel's page.

   If you are familiar with the Make utility, the build.xml file is kind of like makefile, but with much more sane syntax.   If you have never used Make, then no need to worry, the format is pretty simple.  If you don't know what an XML file, also don't panic.    An xml file is just a text file you can make with Notepad or any common text editor.  They are easy to read and pretty simple create.

  So, create a new Java project in your workspace.   Call it 'Hello'.   Create a class called Hello in a new package called 'mypackage'.  Put the following in for the contents of

 Creating Hello Class

The red shows you the important things to check so that your Hello project looks like mine.

 And the project should look like:

Hello project



 Edit to make it look like this:


package mypackage;

public class Hello {

     * @param args
    public static void main(String[] args)
        System.out.println("Hello, World!");


   This highly creative and imaginative program should print Hello, World! to the console and then terminate.   To try it out, right click on the Hello project in the package explorer, and select "Debug As", and then choose 'Java Application' in the popup menu.




<-- Prev Page          Next Page -->










Last Updated on Sunday, 03 January 2010 17:05

Sponsored Links

Bold Inventions, Powered by Joomla!; Joomla templates by SG web hosting