Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

JNI interoperating with .net DLL?

Thread view: 
ntusbalumni - 04 Jun 2007 05:42 GMT
Hi,

How does one get a Java application (JNI) to call functions in
this .NET DLL?
Essential I can't get the JNI DLL to call the .NET DLL (CLI managed
code).
Is this a dead end or is there any other way?

I hope  we don't need to use web services ...
It's just Java trying to talk to .NET DLL on a local machine.

Thanks

Regards,
Choong Leong
Vitaly - 04 Jun 2007 09:29 GMT
See
http://www.sharewareplaza.com/OOJNI-for-NET2-0-low-level-download_49440.html
http://www.sharewareplaza.com/Object-Oriented-JNI-for-NET-low-level-download_407
82.html

http://www.sharewareplaza.com/OOJNI-Add-in-NET-for-VS7-1-download_43587.html

Vitaly

> Hi,
>
[quoted text clipped - 11 lines]
> Regards,
> Choong Leong

I'm protected by SpamBrave
http://www.spambrave.com/
Twisted - 04 Jun 2007 14:46 GMT
> Hi,
>
> How does one get a Java application (JNI) to call functions in
> this .NET DLL?

Looking up appropriate reference ...
Lookup complete.

              DEMONIC INVOCATION FOR BEGINNERS

To begin, obtain a pint of fresh goat's blood. Using this,
inscribe an inverted pentagram on the side of the hardware,
with the word "tfosorciM" in each of the five outer sections.
Then, using JNI, load the DLL and execute a jump to 0x00000666.

For further information, see Demonic Invocation for Necromancers
and Satanists of Intermediate Skill.
Lew - 04 Jun 2007 15:33 GMT
>> Hi,
>>
[quoted text clipped - 13 lines]
> For further information, see Demonic Invocation for Necromancers
> and Satanists of Intermediate Skill.

There is no such thing as Satan.

Signature

Lew

Twisted - 04 Jun 2007 21:16 GMT
> There is no such thing as Satan.

I used to believe that. Then I saw some VB .NET code. And Vista's
EULA. And some of Microsoft's scarier "software as a service" and
"trusted computing" proposals.
Lew - 05 Jun 2007 03:12 GMT
>> There is no such thing as Satan.
>
> I used to believe that. Then I saw some VB .NET code. And Vista's
> EULA. And some of Microsoft's scarier "software as a service" and
> "trusted computing" proposals.

Oh, there's evil, just no Satan.  Still, you make a good case.

Signature

Lew

Brandon McCombs - 05 Jun 2007 02:55 GMT
>>> Hi,
>>>
[quoted text clipped - 15 lines]
>
> There is no such thing as Satan.

I guess that means we are free to kill, rape, and pillage anything we
want without fear of being punished for eternity. Everyone goes to
heaven no matter what.  Time to go out and have some fun!
Lew - 05 Jun 2007 03:12 GMT
Lew wrote:
>> There is no such thing as Satan.

> I guess that means we are free to kill, rape, and pillage anything we
> want without fear of being punished for eternity. Everyone goes to
> heaven no matter what.  Time to go out and have some fun!

That does not follow.

Signature

Lew

Twisted - 05 Jun 2007 07:06 GMT
> Lew wrote:
> >> There is no such thing as Satan.
[quoted text clipped - 6 lines]
> --
> Lew

Mr. McCombs should surely have seen at least one process go into an
infinite loop eating CPU if he routinely engineers software; and if he
doesn't, what is he doing here? Yet if he has, why has he no concept
of limbo? :)
Arne Vajhøj - 06 Jun 2007 02:54 GMT
> How does one get a Java application (JNI) to call functions in
> this .NET DLL?
[quoted text clipped - 4 lines]
> I hope  we don't need to use web services ...
> It's just Java trying to talk to .NET DLL on a local machine.

It is not simple.

Java--(JNI)--C++ Win32 DLL--(COM)--COM wrapper .NET DLL--.NET DLL

should work.

(the C++ Win32 DLL does not need to be written by you - you can
find various COM for Java bridges).

Java--(socket)--wrapper .NET EXE--.NET DLL

is a bit primitive but probably the easiest to implement.

Arne
Tan Choong Leong - 08 Jun 2007 09:58 GMT
Hi Arne,

Thanks! My solution which is similar to yours works!

My solution is:

1. java (JNI) C++ Win32 DLL using LoadLibrary(), GetProcAddress() to call 2.
2. CLR DLL which export extern "C" function API to call 3.
3. Actual .Net DLL in question.

It works by calling as a standalone java class.

Next, what I need is to call functions in this class from a TOMCAT
environment. This fails with unknown reason.

I realised that if I remov the "Actual .NET" function call in the CLR
DLL in step 2. with some dummy data, there is no problem in the Tomcat
environment.

It just beats me that why as a standalone Java class it works but not in
a Tomcat environment.

1. Could it be some security issue?
2. or path problem?

All Dlls are in C:/windows/system32

An excerpt from the error logs:
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  Internal Error (0xe0434f4d), pid=508, tid=3964
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_01-b06 mixed mode, sharing)
# Problematic frame:
# C  [kernel32.dll+0x12a5b]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x03704c00):  JavaThread "http-8081-1" daemon
[_thread_in_native, id=3964]

siginfo: ExceptionCode=0xe0434f4d, ExceptionInformation=0x80070002

Registers:
EAX=0x04e4eb3c, EBX=0x00083a60, ECX=0x00000000, EDX=0x00000025
ESP=0x04e4eb38, EBP=0x04e4eb8c, ESI=0x04e4ebc8, EDI=0xe0434f4d
EIP=0x7c812a5b, EFLAGS=0x00000202
Blah blah blah.....

>> How does one get a Java application (JNI) to call functions in
>> this .NET DLL?
[quoted text clipped - 19 lines]
>
> Arne
Arne Vajhøj - 09 Jun 2007 19:15 GMT
> My solution is:
>
[quoted text clipped - 11 lines]
> DLL in step 2. with some dummy data, there is no problem in the Tomcat
> environment.

What does the actual implementation do ?

> It just beats me that why as a standalone Java class it works but not in
> a Tomcat environment.
[quoted text clipped - 30 lines]
> EIP=0x7c812a5b, EFLAGS=0x00000202
> Blah blah blah.....

Arne
Tan Choong Leong - 11 Jun 2007 02:28 GMT
Hi Arne,

The actual .NET dll is actually a driver provided by a third party
vendor that can communicate with a device using socket (TCP/IP). I do
not have the source code of this driver or knows the protocol of this
device. I just have some function call definition (by looking at the dll
from the object browser) and some sample code.

Regards,

Choong Leong

>> My solution is:
>>
[quoted text clipped - 50 lines]
>
> Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.