B4J Question COM Server integration

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hello,
I would like to interface my app with a COM server(ActiveX object) is anybody tell me if is possible or how can i do that ?
upload_2018-7-12_17-26-3.png
 

keirS

Well-Known Member
Licensed User
Longtime User
I don't think that it is possible.

In theory it is. There are several Java libraries that use JNI to call COM objects. The free ones are all quite old though and the commercial ones are expensive.
 
Upvote 0

StarinschiAndrei

Active Member
Licensed User
Longtime User
In theory it is. There are several Java libraries that use JNI to call COM objects. The free ones are all quite old though and the commercial ones are expensive.
I tried to google it but no result. I will digging .... it should be nice to have a solution to use directly from my app. Thank you for your advice.
 
Upvote 0

Don Oso

Active Member
Licensed User
Longtime User
You can integrate that with JACOB i do a simple Test using Excel its necessary extend this in order to use all the methods and property of the Activex object.

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

#MergeLibraries: True
#AdditionalJar: jacob.jar
#AdditionalJar: commons-collections4-4.1

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private ocx As activeXComponent
    Private Button1 As Button
    Private Label1 As Label
End Sub

Sub AppStart (Form1 As Form, Args() As String)
  
  
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
  
  
    ocx.Initialize("Excel.Application")
  

  
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Button1_Click
  
    Label1.Text=ocx.getProperty("Version")
  
End Sub
 

Attachments

  • excel-jacob.zip
    2.7 KB · Views: 166
  • jacob-1.19.zip
    462.4 KB · Views: 196
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
Hi from austria,

i tried your sample, but i didnt find the right place for jacob-1.19-x64; i get this message:
java.lang.UnsatisfiedLinkError: no jacob-1.19-x64 in java.library.path; i tried to copy this dll file to the external libraries path, to the java jdk/lib path and to windows\system32; where is the correct path for java dll libraries?

Solved: The correct path in my situation is: c:\program files\Java\Jdk 1.8.xxxx\jre\lib\jacobxxx.dll
 
Last edited:
Upvote 0

Don Oso

Active Member
Licensed User
Longtime User
Hi from austria,

i tried your sample, but i didnt find the right place for jacob-1.19-x64; i get this message:
java.lang.UnsatisfiedLinkError: no jacob-1.19-x64 in java.library.path; i tried to copy this dll file to the external libraries path, to the java jdk/lib path and to windows\system32; where is the correct path for java dll libraries?

Solved: The correct path in my situation is: c:\program files\Java\Jdk 1.8.xxxx\jre\lib\jacobxxx.dll

Hi rboeck , you must put the .dll in the same directory of your compiled .jar, in your case put the .dll in Objects directory .

regards
 
Upvote 0
Top