Speaking of the basics of Ant, since a JVM is required to run, just recognizing the JRE is enough. However, if the build process must compile classes, then it will depend on the Java compiler, and if it does not find it, then the assembly will fail.
You can configure Ant to use one of several Java compilers, however I will talk about Oracle javac for an explanation below. Here are the alternatives ...
1) If the JRE recognized by Ant for its execution is a subdirectory in the JDK, it will raise the JDK level and determine the necessary resources.
2) If the JAVA_HOME environment variable is set to JVM (and not JRE), then Ant will be able to compile Java artifacts
3) Alternatively, according to the Ant documentation, JAVACMD can be configured in an OS-specific batch file (antrc_pre.bat for Windows) located under your home directory (and not with Ant), then it will recognize the JVM. Please note that JAVACMD must reference the full path of Java.exe in the bin folder, and not the JVM home.
4) As an alternative, the Ant command line can accept a list of libraries using the -l options. Pass the tools.jar parameter to -l and that will be enough.
5) Finally, the fork attribute of the JavaC task can be set as described above. Keep in mind that this is resource intensive and not recommended.
source share