Java2OP.exe, the Native Bridge File Generator for Android
Go Up to Command-Line Utilities Index
Java2OP.exe ("Java To Object Pascal") is a command-line tool that you can use to generate Delphi native bridge files from Java libraries (JAR or class files). You can use the generated files to provide your Delphi applications access to those Java libraries on Android. See Using a Custom Set of Java Libraries In Your RAD Studio Android Apps.
Java2OP.exe is installed by RAD Studio as part of the Android platform target support. If the Android platform target is installed, it can be found in the bin\converters\java2op folder within the RAD Studio installation. So, for example, in RAD Studio Alexandria 11.0, the full path is:
C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\converters\java2op\Java2OP.exe
To use this tool, simply call the tool with any combination of options that you like:
You must specify at least one input option that indicates what content you want to include in the output Delphi native bridge file.
Your output native bridge file does not include members that are part of the built-in RAD Studio Java libraries for Android unless you explicitly specify those members using the
-classes parameter. If any of the classes that you specified depends on members from the built-in RAD Studio Java libraries for Android, the resulting native bridge file does not redeclare those members; instead, it includes the RAD Studio units that already declare those members.
Space-separated list of names of classes or packages to export.
Space-separated list of input Java compiled libraries (
Space-separated list of input folders containing Java source files (
File name of the output unit.
Exporting some classes and packages from the Android API:
Java2OP.exe -classes android.net.ConnectivityManager android.location.*
Exporting all classes from
Java2OP.exe -jar mylib.jar
Exporting a single class from
Java2OP.exe -jar mylib.jar -classes com.mypackage.ClassName
Exporting all the classes from a folder of Java sources specifying the file name of the output Delphi unit:
Java2OP.exe -src myproject/src -unit Android.JNI.UnitName
- “Missing JDK. Please install JDK 1.7+ or make sure that it is on your PATH”
If you have installed the JDK and you still get this error, the reason is that the JDK binary folder has not been found in any of the paths in your
PATH environment variable. Add the
bin folder of your JDK installation directory to your
For example, from the command line:
SET PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_25\bin
- “EListError error raised, with message : Duplicates not allowed”
You specified a source or JAR file more than once.
Java2OP.exe includes the Android API as input by default, you also get this error if you include the Android API JAR file manually using the
-jar option. For example, this does not work:
Java2OP.exe -jar android.jar
If you want to extract members from the Android API, simply specify a
-classes option. For example:
Java2OP.exe -classes android.animation.*