The j2objc tool translates specified Java source files into either Objective-C or Objective-C++ sources for use in an iOS application.

j2objc [ options ] file1.java ...

The following options are supported. For options that take a path, multiple directories and jar files are separated by a ':', like is done with the java and javac commands.

Common options

-sourcepath <path>
Specify where to find input source files.
-classpath <path>
Specify where to find user class files.
-d <directory>
Specify where to place generated Objective-C files.
-encoding <encoding>
Specify character encoding of source files (UTF-8 default).
-source <release>
Provide source compatibility with specified release.
Generate debugging support.
-l, --list
List files that are translated.
-v, --verbose
Output messages about what the translator is doing.
Make all warnings into errors.
-h, --help
Print this message.

Translation options

Option forwarded directly to the Java compiler (see javac help for details).
Don't issue compiler warnings when native code accesses inherited constructors.
Translate dependent classes if they are out-of-date (likejavacdoes).
Generates class properties for static variables and enum constants.
--dead-code-report <file>
Specify a ProGuard usage report for dead code elimination.
Translate Javadoc comments into Xcode-compatible comments.
Report warnings when translating Javadoc comments.
-external-annotation-file <file>
Specify the most common annotations that affect transpilation in a Java Annotation Index File (format defined by the Checker Framework).
Do not generate debugging support.
Generate debugging support with relative paths.
Generate deprecated attributes for deprecated methods, classes and interfaces.
Pass a Java <flag>, such as-Xmx1G, to the system runtime.
--mapping <file>
Add a method mapping file.
Do not generate class properties for static variables and enum constants.
Don't rewrite expressions that would produce unsequenced modification errors.
Do not generate Objective-C nullability annotations.
Don't create directories for Java packages when generating files.
Generates headers with guards around each declared type. Useful for breaking import cycles.
Do not generate Objective-C wrapper methods for constructors and static methods. (J2ObjC generates C functions for these kinds of executables)
Converts Nullable and Nonnull annotations to Objective-C annotations.
Option forwarded directly to the Java compiler (see javac help for details).
--prefix <package=prefix>
Substitute a specified prefix for a package name.
--prefixes <file>
Specify a properties file with prefix definitions.
Generates output files with the same relative paths as the input files.
-processor <class1>[,<class2>...]
Names of the annotation processors to run; bypasses default discovery process.
-processorpath <path>
Specify where to find annotation processors.
Generate or exclude specific support needed for Java reflection.
--reserved-names <file>
Avoids redefining identifiers present in system headers.
Generates accessor methods for static variables and enum constants.
Removes methods that are marked with aGwtIncompatibleannotation, unless its value is known to be compatible.
Do not generate metadata needed for Java reflection (note: this will significantly reduce reflection support).
Generate code that facilitates Swift importing (equivalent to --class-properties --nullability --swift-enum).
Disables generation of Swift-like enum case names.
Option forwarded directly to the Java compiler (see javac help for details).
-t, --timing-info
Print time spent in translation steps.
Print time spent in translation steps.
Generate Objective-C code to support Automatic Reference Counting (ARC).
Generate Objective-C code to support iOS manual reference counting (default).
Version information.
-x <language>
Specify what language to output. Possible values are objective-c (default) and objective-c++.
Print help for non-standard options.

Nonstandard options

Boot path used by translation (not the tool itself).
Enable all warnings.
Disable all warnings not mandated by the Java Language Specification.
Disable warning xxx, where xxx is one of the warning names supported for -Xlint:xxx, below.
Warn about unnecessary and redundant cast expressions.
Warn about the use of deprecated items.
Warn about items that are documented with an @deprecated Javadoc comment, but do not have a @Deprecated annotation.
Warn about empty statements.
Check switch blocks for fall-through cases and provide a warning message for any that are found.
Warn about finally clauses that cannot complete normally.
Warn about unchecked operations on raw types.
Warn about missing serialVersionUID definitions on serializable classes.
Warn about serial methods called on instances.
Give more detail for unchecked conversion warnings that are mandated by the Java Language Specification.
Warn about unsafe usages of variable arguments (varargs) methods, in particular, those that contain non-reifiable arguments.
Warn if JSNI (GWT) native code delimiters are used instead of OCNI delimiters.

See Also