2

The Ant manual (https://ant.apache.org/manual/install.html) states:

Note: If a JDK is not present, only the runtime (JRE), then many tasks will not work.

We are trying to get the JDK out of our environment and just use the JRE and this is the last application we use that requires the JDK, but does not supply its own copy.

We have tested using Ant with the JRE and so far, none of the Tasks we use fail under the JRE. Before we commit to making this change, does anyone know what Tasks do not work with the JRE? We just don't want to shoot ourselves in the foot down the road.

Keith Davis
  • 351
  • 5
  • 14

3 Answers3

2

In fact things are binary : either the Ant tasks that you execute require a JDK such as a compilation task (javac) and in this case the Ant build will fail as a JRE doesn't have the compiler executable or your tasks don't require a JDK such as a file copy task and in this case the Ant build will be able to process the task.

Note that the official documentation states also that for the current version (1.10), the JDK appears as required :

For the current version of Ant (1.10), you will also need a JDK installed on your system, version 8 or later required. The more up-to-date the version of Java, the more Ant tasks you get.

So to prevent any side effect, according to the used version you should ensure to use a JDK and not a JRE.

davidxxx
  • 125,838
  • 23
  • 214
  • 215
  • Though I appreciate the comments and the sentiment, it's worth the risk for us to be able to not have to worry about installing the JDK and just use the JRE, if we can make it work without it. – Keith Davis Jun 27 '18 at 19:57
1

The JDK is required in order to compile Java code to bytecode. <javac> and <jspc> definitely need it, and probably a bunch of related tasks too.

But the golden rule should always apply - if you're not sure, just test it.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
1

First it helps to understand the difference between the JDK and JRE.

JRE is everything necessary to run a Java application. It contains the JVM as well as some operational tools and browser plugins.

The JDK contains the JRE, plus a java compiler, documentation generation and debugging tools.

Any Ant compilation and documentation tasks require the JDK, since that's the package that includes the tools it tries to execute.

Tasks not dependant on the extra tools included with the JDK will function as normal.

Tasks that definitely need the JDK: Depend, Javac, JspC, Javadoc, Javah

References:

What is the difference between JDK and JRE?

https://ant.apache.org/manual/tasksoverview.html

Stephan
  • 666
  • 8
  • 23
  • We aren't using any of those (and won't since those seem to all be Java related tasks and we use Ant to build a PHP application). – Keith Davis Jun 27 '18 at 19:58
  • 1
    You'll probably be fine then. Thats the only consequential difference that I know of. – Stephan Jun 27 '18 at 20:02