0

I wrote a sample app when trying out java.

calculator/Calc.java

package calculator;

public abstract class Calc {
    public static float Add(float f1, float f2) {
        return f1 + f2;
    }
    public static float Subtract(float f1, float f2) {
        return f1 - f2;
    }
}

Main.java

import calculator.Calc;

public class Main {
    public static void main (String[] args) {
        System.out.println("1+1=" + Calc.Add(1f, 1f));
        System.out.println("1-0.5=" + Calc.Subtract(1f, 0.5f));
    }
}

I managed to compile these classes using jdk into their class files.

Browsing on the web, I found a package called Ant which allows to compile files too. Compiling with Ant also gives me the java class files.

What I want to know is, whats the need for Ant when I can compile my classes directly using jdk without writing any configuration file. Is investing some time into Ant any good when I can build my code using jdk straight away?

techprism
  • 27
  • 1
  • 8

1 Answers1

1

Ant is a build automation tool. It can be used to not only compile classes but also run those classes, test those classes,generate javadocs. Mainly used for independent deployment and/or testing of an application.

whats the need for Ant when I can compile my classes directly using jdk without writing any configuration file.

Check this out.

Is investing some time into Ant any good when I can build my code using jdk straight away?

Depends on what you want to do with our code. Look up Maven and Gradle as well. Gradle is the newest among them and arguably better as well.

xmacz
  • 394
  • 1
  • 5
  • 14
  • I was able to compile classes, archive them and even package them using ant. Its useful with a few lines of configuration. I think its something I was looking for. Thanks for your reply. – techprism Jul 05 '17 at 16:28