Click to See Complete Forum and Search --> : dll issue
erankushmehta
February 27th, 2006, 05:18 AM
i have a dll coded in vb.net & it has to be imported in java.This seems to be not possible.
Is there any way that i can do the same through vc++ or in other words use the vb.net dll to be made accessible to java? :wave:
Kindly guide. :wave:
Regards,
Ankush
Siddhartha
February 27th, 2006, 05:31 AM
If the VB DLL is an ActiveX / COM DLL, there should be a possibility to use it in the Java World.
Isn't it one?
erankushmehta
February 28th, 2006, 07:31 AM
If the VB DLL is an ActiveX / COM DLL, there should be a possibility to use it in the Java World.
Isn't it one?
This isn't
Siddhartha
February 28th, 2006, 07:32 AM
How did you verify this?
erankushmehta
February 28th, 2006, 07:38 AM
i asked it from the guy who actually made it.
Siddhartha
February 28th, 2006, 07:43 AM
I would rather you opened the dll in Dependency Walker, and check if exported function DllRegisterServer exists.
www.dependencywalker.com (http://www.dependencywalker.com)
EDIT: VB.NET DLL, is it? Then, check if you can register assembly using regasm. If assembly registration succeeds, you can use it as a COM / ActiveX DLL from any client. Try and let us know...
erankushmehta
March 1st, 2006, 12:26 AM
EDIT: VB.NET DLL, is it? Then, check if you can register assembly using regasm. If assembly registration succeeds, you can use it as a COM / ActiveX DLL from any client. Try and let us know...
Kindly elaborate on assembly registration & how to do the same using regasm.Thanks.
erankushmehta
March 1st, 2006, 02:20 AM
well, i did it using regasm & i think it was registered because there was no error message thrown up, just a flash of black screen & then it disappears.
So, does this mean, i can use it as a com,activeX directly with java .
regasm C:\Encryptdecrypt.dll
well, is this the process you suggested for assembly registration, Siddhartha
:wave:
Regards,
Ankush
Siddhartha
March 1st, 2006, 03:29 AM
just a flash of black screen & then it disappears. To see what the black screen said, open the command line (Start --> Run --> cmd --> Enter)and enter the regasm command there.
well, is this the process you suggested for assembly registration, SiddharthaYes... This (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfassemblyregistrationtoolregasmexe.asp) is it.
Now, to take you further and help you find someone who knows how to use a COM DLL in Java, I'll move this thread to the Java Forum.
Siddhartha
March 1st, 2006, 03:30 AM
[ redirected ]
Regards,
Siddhartha
erankushmehta
March 1st, 2006, 04:16 AM
Now, to take you further and help you find someone who knows how to use a COM DLL in Java, I'll move this thread to the Java Forum.
Kindly Guide. :wave:
Siddhartha
March 1st, 2006, 04:23 AM
I did a search and found these two articles that might be of interest -
Using COM Objects in Java - Article 1
(http://e-docs.bea.com/wls/docs61/jcomreference/UsingCOMObjectsfromJava.html)
Using COM Objects in Java - Article 2 (http://research.microsoft.com/%7Echadv/java_com2.htm)
Are you programming in Java on the .NET framework (J#), or are you doing it outside the VS IDE?
erankushmehta
March 1st, 2006, 04:44 AM
using it outside VS IDE. i am using Java.
erankushmehta
March 1st, 2006, 05:03 AM
it registers successfully on a machine with .net architecture on it. But the machine on which i am developing my application & want to import the dll doesn't have .net architecture.
So will it work out??
Siddhartha
March 1st, 2006, 05:04 AM
it registers successfully on a machine with .net architecture on it. But the machine on which i am developing my application & want to import the dll doesn't have .net architecture.
So will it work out??Obviously, not. ;)
dlorde
March 1st, 2006, 05:08 AM
The standard way of using native DLLs from Java is to use the Java Native Interface (http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html).
Today, most software exists, not to solve a problem, but to interface with other software...
I. O. Angell
Siddhartha
March 1st, 2006, 05:11 AM
...The complication in this case is that the DLLs are non-Native.
erankushmehta
March 1st, 2006, 05:26 AM
i heard something of 'wrapper dll'.....not sure about it
erankushmehta
March 1st, 2006, 05:27 AM
i heard something of 'wrapper dll' in c++.....not sure about it.This wrapper dll will wrap vb.net dll & will be imported by java..something like that :confused:
Siddhartha
March 1st, 2006, 05:28 AM
One cannot use a .NET DLL without having a .NET framework installed the same way as one cant run a Java Application without having the Java Run-Time installed.
You need to resolve failing pre-requisites before you proceed.
erankushmehta
March 1st, 2006, 06:28 AM
Let me Quote from a forum.I could not get much.Help if someone can simplify the things.
How to call VB code from Java:
Here is very simple method of how to execute your VB code from the java. Author assumes that you are having preliminary knowledge of Java jni technology, VB and VC++. The steps involved are as follow:
1) Making the Java File by using the LoadLibrary Function which will call the dll.
2) Compiling the java file and also compiling again with javah to make the .h file for the c++ or c classes.
3) Now Start Making the Module in VB and make the dll from it. The function contained in this module will be used by the java code.
4) Now Start Making the MFC dll or simple dll in VC++ . Note the calling procedure for the function will be java code calling the dll made
in VC++ (MFC or simple) the VC++ function will call the VB dll made in VB environment. The same procedure can repeated for
the parameter passing from Java to VB. For more help on this topic contact the author regarding the same.
Here is the Java File which is calling the VC++ dll ( I had made the dll in MFC but you can make the same in another environment)
public class VBCallFromJava
{
public native void callvb();
static
{
System.loadLibrary("VCCallVB");
}
public static void main(String args[])
{
VBCallFromJava ft = new VBCallFromJava();
ft.callvb();
}
}
Don't forget to compile with the javah option which will make the .h file in the current directory
javah -jni VBCallFromJava
Here is the code for the VB Module. Make the dll from the same. Don't forget to include the .h file
generated by the java and the jni.h file which you will find in the jdk tool.
Public Function TestCall()
MsgBox ("This Is Called From The VB Environment....")
End Function
Here is the code for the VC++ dll here I had used the MFC dll however you can use the simple dll also.
Note add the following lines to your StdAfx.h file to call VB dll from the VC environment.
StdAfx.h
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#import "VBCallFromVC.dll"
using namespace VBCallFromVC;
#endif // !defined(AFX_STDAFX_H__E2E58D77_4A6F_42F8_B19B_13D0D6BBDDC4__INCLUDED_)
Here is the code for the main VC++ dll I had written the code in the JNIEXPORT itself so that program
jumping is avioded.
/** Here is the Method which is defined
*/
JNIEXPORT void JNICALL Java_VBCallFromJava_callvb
(JNIEnv *, jobject)
{
AfxMessageBox("This is the call from the VC Enviornment......");
HRESULT hr;
CLSID cls;
// Intializing the com component
CoInitialize(NULL);
hr = CLSIDFromProgID(OLESTR("VBCallFromVC.Class1"), &cls);
_Class1 *t;
hr = CoCreateInstance(cls,NULL,CLSCTX_INPROC_SERVER, __uuidof(_Class1),(LPVOID *) &t);
if(FAILED(hr))
{
AfxMessageBox("Failed yaar ");
}
t->TestCall();
AfxMessageBox("Again control in the VC environment...");
}
After completing the whole procedure run the java file and examine the flow of the Program which would like java environment to VC++ environment to VB environment back again to the VC++ environment
and back again to the java environment.
erankushmehta
March 2nd, 2006, 02:26 AM
One cannot use a .NET DLL without having a .NET framework installed the same way as one cant run a Java Application without having the Java Run-Time installed.
You need to resolve failing pre-requisites before you proceed.
Okay, i have installed .net framework.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.