7

There is jar library

native C++ port is not yet available (as DLL)

I need to call from

I have 3 possibilities:

1) Wait until native port is ready 2) Use JAR library from VB via brigde (?), installed JRE required 3) Compile JAR into native DLL using GCJ and use it form VBA

http://www.microsoft.com/germany/msdn/library/office/OfficeVBAUndDieWindowsAPI.mspx?mfr=true

I think: pos. 1 is easy, but I must wait pos. 3 is in practice impossible

Is there some ideas about pos. 2?

Thanks.

hellboy
  • 1,329
  • 5
  • 18
  • 50

3 Answers3

5

It depends on whether you wish to return values from the JAR file or not. If you do not, and just wish to execute a method then you can use a "Shell" (or ShellExecute) from VB as follows:

Shell("java.exe -jar " & <yourJARFile>)

If you do need to return a value then you will more than likely need a bridge - similar discussion here (for VB.NET, but principle is the same): Can you use Java libraries in a VB.net program?

Based on that most bridges that people have created are for .NET and not for VBA/6 so you would maybe need to create your own somehow, or perhaps create a .NET DLL that is then consumed by your VBA code.

Community
  • 1
  • 1
i_saw_drones
  • 3,398
  • 1
  • 26
  • 48
  • 1
    [VBA jar Dateiaufruf (DE)](http://www.java-forum.org/java-basics-anfaenger-themen/114098-vba-jar-dateiaufruf.html) and [Java aus VB-Script starten](http://www.vb-paradise.de/programmieren/grundlagen/45734-java-aus-vb-script-starten/) – hellboy Mar 16 '11 at 08:31
3

This can be performed via a VBA macro using Obba. (Disclaimer: I am working on Obba).

Christian Fries
  • 14,119
  • 9
  • 51
  • 65
0

There are couple approaches to be used when you require 2 different technologies to speak, go for Objects/Methods publications using:

  • Corba & (or RMI or JMS)
  • SOAP
  • RESTful API
  • WebServices
  • File Data exchange.
  • IPC Pipeline

Depending on the complexity you will take your solution.

Calling 'java.exe' runs the library in a VM, you can produce an output using a external resource but only the 3 first are meant to exchange objects in a heterogen solution.

leandr0garcia
  • 51
  • 1
  • 2