Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey, Delphi Android, Delphi IOS

Utility To Generate Java Android Class And JAR File Interfaces For Delphi XE5 Firemonkey

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE5 Firemonkey Java Class Jar To Pascal | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSThere is a utility that was recently released called Java2Pas and it creates an interface out of a Java class or Jar file for Delphi XE5 Firemonkey. The goal being that it will allow you to create interface files for all kinds of Android JAR libraries. There is not much information about the utility but it appears to come from a company called Software Union in Luxembourg. It seems like the utility is a paid utility with a free version but I don’t see anywhere to register it. When you create an interface file it is labeled with “unregistered evaluation copy” text (there is also an ini file with a place for a key). Update: You can email them to purchase via Paypal or wire (the cost is EUR 50 + VAT). In any event the utility creates interface(JObjectClass)’s for all class files but will only create interface(JObject)’s for classes in the Android namespace. I’m not sure how useful it is without the JObject interfaces however. There is a post up on DelphiPraxis where the author explains the utility here. On the forum post the example interface is the AlarmManager from Android. I used the utility against the SQLCipher JAR file and this is some of what it created:
//
// Generated by JavaToPas 20140406 - 210726
// *** unregistered evaluation copy ***
////////////////////////////////////////////////////////////////////////////////
unit net.sqlcipher.database.SQLiteDatabase;

interface

uses
AndroidAPI.JNIBridge,
Androidapi.JNI.JavaTypes,
net.sqlcipher.database.SQLiteTransactionListener,
net.sqlcipher.database.SQLiteDatabase_CursorFactory,
net.sqlcipher.database.SQLiteDatabaseHook,
Androidapi.JNI.GraphicsContentViewText,
net.sqlcipher.database.SQLiteClosable,
net.sqlcipher.SQLException,
net.sqlcipher.database.SQLiteDatabase_SyncUpdateInfo,
net.sqlcipher.database.SQLiteDatabaseCorruptException,
net.sqlcipher.database.SQLiteStatement,
net.sqlcipher.Cursor,
net.sqlcipher.database.SQLiteCursorDriver,
net.sqlcipher.database.SQLiteCursor,
android.content.ContentValues,
net.sqlcipher.database.SQLiteCompiledSql,
android.util.Pair;

type
JSQLiteDatabase = interface;

JSQLiteDatabaseClass = interface(JObjectClass)
['{9366527F-7E37-4BEF-9E18-93E69A02D5CA}']
function compileStatement(sql : JString) : JSQLiteStatement; cdecl;         // (Ljava/lang/String;)Lnet/sqlcipher/database/SQLiteStatement; A: $1
function create(factory : JSQLiteDatabase_CursorFactory; password : JString) : JSQLiteDatabase; cdecl;// (Lnet/sqlcipher/database/SQLiteDatabase$CursorFactory;Ljava/lang/String;)Lnet/sqlcipher/database/SQLiteDatabase; A: $9
function delete(i : Integer; numArgs : Integer; e : JSQLiteDatabaseCorruptException; table : JString; whereClause : JString; whereArgs : TJavaArray<JString>; statement : JSQLiteStatement) : Integer; cdecl;// (Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I A: $1
function findEditTable(spacepos : Integer; commapos : Integer; tables : JString) : JString; cdecl;// (Ljava/lang/String;)Ljava/lang/String; A: $9
[...]
end;

[JavaSignature('net/sqlcipher/database/SQLiteDatabase$ActiveDatabases')]
JSQLiteDatabase = interface(JObject)
['{DB8BBC42-3A10-47B7-882B-DAA528BE65C0}']
//
// Unregistered copy: Implementation not written
//
end;
There are two other utilities that I know of that will create interface files out of class files for Android. The first one, Android 2 Delphi Import tool, has no free trial and has to be purchased with Bitcoins. The second one, JavaImport For Android, has a free trial but only works on Java class files directly and not on JAR files. I’d like to see JavaImport handle JAR files directly.

Head over and download the Java2pas utility from the Software Union website.

Exit mobile version