Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodDelphiFiremonkeyUtility

Create Android Java JAR Interface Files For Delphi XE7 Firemonkey With Java2OP

Delphi XE7 Firemonkey Android Java To Object Pascal JAR Interface ConverterEmbarcadero has released the Delphi XE7 Firemonkey utility called Java2OP which will take a JAR or .java files and create Object Pascal interface files for them. David Intersimone from Embarcadero has a blog post about it here. If you want to use third party SDKs or use some Android API functionality that is not provided in the Firemonkey RTL this is the utility to use to make it easier to access. Previously for Delphi XE5 and Delphi XE6 there were three different utilities that provided different ways for creating Object Pascal interface files for Android JAR libraries. I used the Java2Pas utility to create interface files for the entire Android SDK. Java2OP allows you to define a subset of the specific Java sources and you can use it against either a JAR file or a directory of .java files. Java2OP requies Java and the JDK 1.7+ for it to run and the JDK must be in your path. As you may know Delphi XE7 provides the new option to add third party JAR files automatically into a project and this Java2OP creates the interface files you need. You should also be able to use it with AppMethod. Here is the Readme file from Java2OP:
Install
-------

To use Java2OP.exe, you must download and install Java and the JDK 1.7+.
You will need to add the bin folder of your JDK installation directory to your PATH.
For example, from the command line:
SET PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_25\bin
Usage
-----
To use this tool, simply call the tool with any combination of options that you like:
Java2OP.exe [options]

You must specify at least one input option that indicates what content you want to
include in the output Object Pascal native bridge file.

Your output native bridge file does not include members that are part of the built-in
Java libraries for Android unless you explicitly specify those members using the
-classes parameter. If any of the classes that you specified depend on members from the
built-in Java libraries for Android, the resulting native bridge file does not
redeclare those members; instead, it includes the units that already declare
those members.
Input Options
-------------
-classes Space-separated list of names of classes or packages to export. -classes lets
you define a specific subset of the specified Java sources (-jar or -source options)
or the Android API.
-jar Space-separated list of input Java compiled libraries (.jar files).
-source Space-separated list of input folders containing Java source files (.java files).
Output Options
--------------
-unit File name of the output unit.
Default: Android.JNI.Interfaces
Examples
--------
Exporting some classes and packages from the Android API:
Java2OP.exe -classes android.net.ConnectivityManager android.location.*

Exporting all classes from mylib.jar:
Java2OP.exe -jar mylib.jar

Exporting a single class from mylib.jar:
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 Object Pascal unit:
Java2OP.exe -source myproject/src -unit Android.JNI.UnitName

Head over and download the full free Java to Object Pascal utility for Delphi XE7 Firemonkey from Embarcadero.

close

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

DelphiIDEShowcaseWindows

Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

DelphiFiremonkeyIDEIOSOSXWindows

DelphiCon 2020 FireMonkey Sessions Available Starting November 19

AndroidC++BuilderDelphiDemoFiremonkeyWindows

Powerful Commercial Gorilla3D Framework Upgraded For Delphi FireMonkey On Windows And Android

Sign up for our Newsletter and
stay informed

5 Comments

Leave a Reply