• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I access the method from .dll created by .net  RSS feed

 
RameSan Rahul
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have a third party .dll file created by .net programmers.
Can I access the native method without working in .net again.
Because the tutorials & articles I have seen mentioned that we have to create a .h file of the java source and the .h file has to be included and implemented agin in the same language(like C , C++). Then again we have to create a library and this library has to be set in the path.

How can I do it?
Can aby one help me on this?
Thanks in advance.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into JNI. The Sun Tutorial is a good start. You may have to write some custom C/C++ just for the purpose.
 
RameSan Rahul
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks James

I have gone thru sun tutorial.
As per my understanding I explain this please correct me if i am not correct.

1. First I create a Java file which loads the library from the .dll.
2. After compiling the source I have to create a header(.h) file.
3. I have to implement the Java native methods using the (.h) in the
native language (i.e, .Net) and then I have to create a shared or
dynamic object library.
4. The library has to be set in the Path
5. Run the java program created in the step 1 as normal program.

Am I correct?
If it is so, in my case , the third party only can work on the native language who knows the functionality defined in the .dll file.
Is it so?

Kindly clarify me.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, you will have to write an interim dll. This ddl lib is written to use the include file generated by the javah program, and it will route the request to the .NET object that you want to access. There is *no* way to directly load and use the .NET object directly from Java.... and unfortunately...


It is also forbidden for a C/C++ component to have a "instance" reference to a .NET object -- only local variables are allowed. So if you need to have a long term access to .NET object, you'll need another .NET object. You may have to write a managed C++ .NET object, which has an instance to the .NET object that you want, and have static getter methods that may be called from the C/C++ (unmanaged) code.

Henry
 
RameSan Rahul
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks henry

Let me try that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!