Call Java methods from VB and C/C++

Bryce McKinlay bryce@mckinlay.net.nz
Wed Oct 1 00:16:00 GMT 2003


On Wednesday, Oct 1, 2003, at 11:29 Pacific/Auckland, Glenn Lewis wrote:

> Can anyone tell me if it is possible to call java
> methods  from Visual Basic (and C/C++)? I need to be
> able to pass (sometimes complex) data to these java
> methods.

I doubt you'd be able to call into compiled Java code directly from VB 
(through JNI you might, but not CNI). However, you could do it with an 
intermediate C++/CNI layer between the VB and Java code. Note the C++ 
code would have to be compiled with GCC.

> I thought I might be able to use gcj and cygwin to
> build a dll and link against that dll from VB.  I got
> as far as creating a simple dll, but am having trouble
> using it from VB (and C/C++). I came across this post
> http://gcc.gnu.org/ml/java/2003-04/msg00004.html Has
> anything changed since then or is this still not
> possible?

AFAIK, DLL support on Windows hasn't improved since then. The new 
BC-ABI will help this along. But, it might work if you compiled your 
intermediate code into the DLL along with the Java stuff, and then 
exported the symbols for your own functions.

Regards

Bryce.




More information about the Java mailing list