tags:

views:

95

answers:

8

I need to reference a C++ dll from my Java project. The method that I need to expose is actually written in Visual Basic. Is there any way to access the Visual Basic code in C++, so that it can eventually be accessed in the Java project?

+1  A: 

You can use OS native DLLs from your Java project using Java Native Interface (JNI):

Andriy Sholokh
+1  A: 

Assuming this is VB 6.0 and not VB.NET, you need to create an MFC DLL wrapper for your VB ActiveX DLL.

Here's more information on Exporting VB DLL Functions.

Jose Basilio
A: 

You have to use JNI (Java Native Interface) technology.

andcoz
A: 

I highly recommend the Java JNI Tutorial.

Andy Pryor
A: 

hi ,as per Andriy Sholokh ,u need to use JNI to communicate with c or c++ from your java project. You have to use native method inside your java code. hope it will help you.

yosanu
A: 

Just to be clear, the core of this question is: how do I get C++ DLL to talk to a VB DLL?

Matt
A: 

jmac posted the original question on my behalf. I needed to find a way to call VB DLL function from a C++ DLL.

I've given up on the VB DLL and opted for a C# DLL. The following link provides a downloadable Visual Studio solution that provides a project called DLLExporter that exports C# functions thus making them available to C++. The VS solution was written in a version earlier than 2010 but the VS 2010 migrator had no problem importing it.

http://www.codeproject.com/KB/dotnet/DllExporter.aspx

It solved my problem.

For the record, I tried to wrap my VB DLL inside the C# DLL but it didn't work. So I just migrated my VB code to C#.

Matt