File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use VB .dll in java

 
Tejas Tambe
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
I want to use a VB generated dll file, in Java. I tried using Syste,.loadLibrary(dllName);
though it is able to load the library success fully it's not able to call the native methods.
On execution it gives me an error saying :
Exception in thread "main" java.lang.UnsatisfiedLinkError
at testJNI.main(testJNI.java:18)
I am not able to find the cause and thus the solution of this problem.
Please help me outtttttttttttt !!!
Regards,
tejas
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to use some JNI (Java Native Interface).
 
Tejas Tambe
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Cindy,
But the problem here is I dunno how to use JNI for a Dll. So can u throw some light on that ???
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did youread the tutorial that I linked you to?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't want to do the interface yourself, I believe that there is an opensource tool called Jacob that will interface your java program with the vb.dll stuff.
http://danadler.com/jacob/
 
Tejas Tambe
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Cindy,
I know about jacob, there's another product by a company called as Ice or something. But, since I want to code by myself and I am not willing to use any third party tools, as I really wish to learn JNI.
I have read the sun.java's tutorial (the same u've asked me to refer), but what I could figure out, that tut. was meant for C or C++.
What these people have asked to do is that create a header file and then include it that header file in your C or C++ program, and then create a .dll out of it. But, Visual Basic does not allow to include/ import any header files, and this is where I fail to proceed.
I have loaded the dll in memory using the System.loadLibrary method(), but when I try to call the native method it gives me the error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: sayHello at testJNI.main(testJNI.java:23)
In the tutorial refered by you, it says to write the function with the same name as it is in the header file created by the javah utility. Even this is not allowed in VB as VB does not support pointers.
I hope this clears my problem.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that you have to create a c++ wrapper for your dll and then use JNI to interface it to java.
Here is an example of how to do this.
Here is a discussion somebody else was having about getting this done.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not write your code in C#. *ducking*
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm . . . something about platform independance . . . what WAS that . . .

Of course as soon as you blend in a vb.dll you have shot your platform independance to hell anyway :roll: .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic