7

I'm working with a JAR library, but a native C++ port (as a DLL) isn't available yet.

I need to access this functionality from VBA, and I'm considering three options:

  1. Wait for the native port to be completed.
  2. Access the JAR library from VBA through a bridge (requiring an installed JRE).
  3. Compile the JAR into a native DLL using GCJ, then call it from VBA (although I think this is practically unfeasible).

I believe option 1 would be the easiest, though it requires waiting. Option 3 seems impractical.

Could you provide any insights or suggestions regarding option 2? Specifically, I'm interested in setting up a reliable bridge between VBA and the JAR library.

Thanks for your assistance!

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

3

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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.