How Can I Extract A Delphi Class From This Java File For Use With Android?
Solution 1:
I am a beginner with Android and I am also trying to interface the FT311. I will share my experience with Java2OP but I am not yet able to get the usbAccessory in Delphi XE7
UsbManager := TJUsbManager.Wrap(SharedActivityContext.getSystemService(TJContext.JavaClass.USB_SERVICE));
AccessoryList := UsbManager.getAccessoryList();
if ( AccessoryList <> nil ) then begin
if ( AccessoryList.Length > 0 ) then begin
Accessory := AccessoryList.Items[0]; <<<<<<< raise an illegal instruction , access violation..
end;
end;
I had many troubles to use java2op but Here are the steps I follow After googling (sorry I don't remember the urls)
create a .jar file with eclipse ADT containing the class you need (I use FT311GPIOInterface.java from the FT31 demo project supplyed by FTDI). It is not as easy because you have to split the demo app into a "android project library" (the one which will produce the .jar) and an "android project" the UI of the demo app. The .jar is build when you build and run the demo app (not when you build the android project library). If you want to test your .jar with the UI app, you have to copy the .jar into the UI app in the directory Libs and then deploy it on the android device I am new to eclipse, there is probably a better way to do it but ... I saw other way to produce the .jar file See brian long web site for another way to
Java2op : It works on a clean XP windows : I use a virtual machine, no delphi XE installed, with java jdk1.7.0_25, java2op installed, no android SDK.
my jar is ft311lib.jar java2op -jar ft311lib.jar -unit com.poco.ft311lib
this produce com.poco.ft311lib.pas
Hope this help
Solution 2:
According the linked documentation about this command line tool, I would do the following:
- create a
src/
folder and putFT311I2CInterface.java
in it. run
java2op.exe
with those args:java2op.exe -source src/ -unit Android.JNI.FT311I2C
Expected output :
Android.JNI.FT311I2C.pas
The -unit
arg specify the output.
The -source
arg specify the input (in your case you need a java source file)
Solution 3:
Java2OP.exe ... is a command-line tool that you can use to generate Delphi native bridge files from Java libraries (JAR or class files).
I suggest to check if you used the tool correctly:
java2op.exe -unit FT311I2CInterface.java
According to the documentation, -unit specifies File name of the output unit
, not the input file. It also says
You must specify at least one input option that indicates what content you want to include in the output Delphi native bridge file.
Try instead:
java2op.exe -source .
Post a Comment for "How Can I Extract A Delphi Class From This Java File For Use With Android?"