Runs the rmic compiler for a certain class.

Rmic can be run on a single class (as specified with the classname attribute) or a number of classes at once (all classes below base that are neither _Stub nor _Skel classes). If you want to rmic a single class and this class is a class nested into another class, you have to specify the classname in the form Outer$$Inner instead of Outer.Inner.

It is possible to refine the set of files that are being rmiced. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns.

This task forms an implicit FileSet and supports most attributes of <fileset> (dir becomes base) as well as the nested <include>, <exclude> and <patternset> elements.

It is possible to use different compilers. This can be selected with the build.rmic property, the compiler attribute, or a nested element. Here are the choices:

The miniRMI project contains a compiler implementation for this task as well, please consult miniRMI's documentation to learn how to use it.

CORBA support

Java 11 removes the Java EE and CORBA packages and rmic no longer supports either -iiop or -idl options. Starting with Ant 1.10.3, the rmic task will fail when using either while running Java 11+ unless you fork the task and explicitly specify an executable.


Attribute Description Required
base the location to store the compiled files. Also serves as the parent directory for any non-Fileset includes, etc. (This functionality has remained unchanged.) See note
destdir the location to store the compiled files.
classname the class for which to run rmic. No
filtering indicates whether token filtering should take place No
sourcebase Pass the -keepgenerated flag to rmic and move the generated source file to the given sourcebase directory. No
stubversion Specify the JDK version for the generated stub code. Specify 1.1 to pass the -v1.1 option to rmic, 1.2 for -v1.2, compat for -vcompat.
Since Ant 1.7, if you do not specify a version, and do not ask for .iiop or .idl files, compat is selected.
No; default is compat
classpath The classpath to use during compilation No
classpathref The classpath to use during compilation, given as reference to a path defined elsewhere No
includes comma- or space-separated list of patterns of files that must be included. No; defaults to all (**)
includesfile name of a file. Each line of this file is taken to be an include pattern No
excludes comma- or space-separated list of patterns of files that must be excluded. No; defaults to default excludes or none if defaultexcludes is no
excludesfile name of a file. Each line of this file is taken to be an exclude pattern No
defaultexcludes indicates whether default excludes should be used or not (yes|no). No; defaults to yes
verify check that classes implement Remote before handing them to rmic No; default is false
iiop indicates that portable (RMI/IIOP) stubs should be generated.
See the note on CORBA support above.
iiopopts additional arguments for IIOP class generation No
idl indicates that IDL output files should be generated.
See the note on CORBA support above.
idlopts additional arguments for IDL file generation No
debug generate debug info (passes -g to rmic) No; defaults to false
includeAntRuntime whether to include the Ant run-time libraries No; defaults to yes
includeJavaRuntime whether to include the default run-time libraries from the executing JVM No; defaults to no
extdirs location of installed extensions No
compiler The compiler implementation to use. (See the above list of valid compilers.) No; defaults to the value of the build.rmic property, if set, and the default compiler for the current JDK otherwise
executable Complete path to the rmic executable to use in case of the forking or xnew compiler. Since Ant 1.8.0. No; defaults to the rmic compiler of JDK that is currently running Ant
listfiles Indicates whether the source files to be compiled will be listed. Since Ant 1.8.0. No; defaults to no


Parameters specified as nested elements

classpath and extdirs

Rmic's classpath and extdirs attributes are path-like structure and can also be set via a nested classpath and extdirs elements.


You can specify additional command line arguments for the compiler with nested <compilerarg> elements. These elements are specified like Command-line Arguments but have an additional attribute that can be used to enable arguments only if a given compiler implementation will be used.

Attribute Description Required
value See Command-line Arguments. Exactly one of these
prefix See Command-line Arguments. Since Ant 1.8. No
suffix No
compiler Only pass the specified argument if the chosen compiler implementation matches the value of this attribute. Legal values are the same as those in the above list of valid compilers.) No


Since Ant 1.8.0

A path-like structure holding the classpath to use when loading the compiler implementation if a custom class has been specified. Doesn't have any effect when using one of the built-in compilers.

Any nested element of a type that implements RmicAdapter

Since Ant 1.8.0

If a defined type implements the RmicAdapter interface a nested element of that type can be used as an alternative to the compiler attribute.


<rmic classname="com.xyz.FooBar" base="${build}/classes"/>

runs the rmic compiler for the class com.xyz.FooBar. The compiled files will be stored in the directory ${build}/classes.

<rmic base="${build}/classes" includes="**/Remote*.class"/>

runs the rmic compiler for all classes with .class files below ${build}/classes whose classname starts with Remote. The compiled files will be stored in the directory ${build}/classes.

If you want to use a custom RmicAdapter org.example.MyAdapter you can either use the compiler attribute:

<rmic classname="com.xyz.FooBar"

or a define a type and nest this into the task like in:

<componentdef classname="org.example.MyAdapter"
<rmic classname="com.xyz.FooBar"

in which case your compiler adapter can support attributes and nested elements of its own.