I have an old VB6 program that is 10 years old, and it is communicating with the COM interface of a commercial program of the time, PADS Layout 2005. I would like to reuse my fully functional code contained in the VB6 program I wrote at the time in a Java program, and also since all the examples for communicating with PADS layout are done in VB6 or a proprietary VB scripting API, it would be very hard to do anything else, practically.
So I want to put all essential code from the VB6 program into a VB6 ActiveX DLL, wrap it into a VC++ DLL and access functions in it it with JNI using Java.
I found a simple example, that looked very reasonable, that worked to a certain point:
It is just adding up 2 int numbers converted to String and displayed, the activeX dll VB6 function used:
Public Function add(ByVal a As Integer, ByVal b As Integer)
MsgBox "Result: " + CStr(a + b) 'Convert to String function
I did the exact same thing as suggested in example, same folder structure and file names, and I got all the way to creating the header files, as described at the link above:
4) Now create the JNI header files for the class file using the following command
javah –jni NativeImpl
All I get is various error messages, I tried several things:
I am using an XP virtual machine, Visual Studio 6 installed, which includes Visual Basic 6 and Visual C++ 6.0 to make the wrapper DLL. I am using older Java 1.6, and still I slightly had to change code to avoid using a depricated method. I also did a decompile on the Java class file I created, just to check, but it looks fine to me:
// Decompiled by DJ v126.96.36.199 Copyright 2009 Atanas Neshkov Date: 4/18/2014 7:18:57 AM
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: NativeImpl.java
public class NativeImpl
public native void add(int i, int j);
public static void main(String args)
DataInputStream datainputstream = new DataInputStream(System.in);
NativeImpl nativeimpl = new NativeImpl();
System.out.println("Enter number 1 & 2:");
int i = Integer.parseInt(datainputstream.toString());
int j = Integer.parseInt(datainputstream.toString());
The only change I had to make in the OS is adding a CLASSPATH, so that the javac compiler could be found on command line. that should be enough, right?:
I have all the files, in the zip file on my Google drive:
(Expert Exchange did not let me upload a zip containing a dll)
Thank you for your help.