The Artima Developer Community
Sponsored Link

Java Answers Forum
Callin Windows-DLL from java program

7 replies on 1 page. Most recent reply: Dec 5, 2005 12:26 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 7 replies on 1 page
Markus Weigert

Posts: 9
Nickname: weigi
Registered: Jul, 2002

Callin Windows-DLL from java program Posted: Jul 28, 2002 8:22 PM
Reply to this message Reply
Advertisement
Hello,

I want to call a Function in C:\Windows\System\Shell32.dll
which returns the path to the exe-file
which is registered as application for a given
file-format!
The functions signature is:

FindExecutable(String file, String appPath, String result);

The String "result" contains the exe-path after
FindExecutable has returned!

My problem is that I don't know how to access
this function cause JNI doesn't help me here
cause I didnt write the dll myself and cant make
a header file.
(at least I don't know how to do)!!!
From VB it's all no problem!

Thank you very much,
Markus


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Callin Windows-DLL from java program Posted: Jul 29, 2002 2:12 PM
Reply to this message Reply
Yes, JNI does help you here. You simply write a native method that itself calls the function in the DLL and returns the result. For instance, you might define this:
    public native String findExecutable( String file, String path ) throws FileNotFoundException;
Then in your C++ code, you would simply call the Windows API function.

Markus Weigert

Posts: 9
Nickname: weigi
Registered: Jul, 2002

Re: Callin Windows-DLL from java program Posted: Jul 29, 2002 3:27 PM
Reply to this message Reply
Thank you very much for your help,
I will try this!

Greetings,
Markus

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Callin Windows-DLL from java program Posted: Jul 31, 2002 7:40 PM
Reply to this message Reply
Hi Matt,
IBM has a bridge available on their alphawork web site !
Have you ever tried it ?
I am looking for some feed back on the tool to know if it's worth!

Thomas,

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Callin Windows-DLL from java program Posted: Jul 31, 2002 10:13 PM
Reply to this message Reply
Hi Thomas,

What do you mean by bridge (and do you know what its name is, or what to search for on the IBM site)?

I'm interested in a Java library that allows simple access to COM automation objects (such as those used by the Windows Scripting Host). I've created some automation objects that are quite handy for JScript and Python (and any other language that can easily access COM automation objects) and I'd like to be able to use those with Java applications, as well. I suppose if all else fails, it wouldn't be too tough to make my own JNI that does this (maybe this is exactly what the bridge you refer to does?).

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Callin Windows-DLL from java program Posted: Aug 1, 2002 1:39 PM
Reply to this message Reply
This is a technology licenced by I.B.M. after prooving itself usefull on the alphawork site.

http://www.alphaworks.ibm.com/tech/bridge2java

I was wandering if somebody had used it & if yes, if was any good ?
U know that IBM can give the best & the worst ...

Rgds,

Thomas SMETS,
SCJP 2 - Brussels

Goh Kok Keong

Posts: 1
Nickname: wlogan
Registered: Dec, 2005

Re: Callin Windows-DLL from java program Posted: Dec 5, 2005 7:34 AM
Reply to this message Reply
Hi Matt,

I have came across this very old message in my search for using my COM DLL in Java.

My initial impress when I was doing COM was that it can also be used in Java but I haven't been success in finding a easy way to do it.

May I know is there any easy way of doing it? If not, is there any article or website I can have a good read up on JNI?

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Callin Windows-DLL from java program Posted: Dec 5, 2005 12:26 PM
Reply to this message Reply
I think there are commercial libraries that facilitate use of COM in Java. I don't know if there is anything in the currrent Java library for this (there might be, I just haven't been doing a lot of Java programming for the last few years, so I don't know).

As far as Java Native Interface information, you can find sufficient information on Sun's site. I think there is a tutorial on it. Google for JNI Tutorial and the like and you're sure to find it. Using JNI, you'd probably use ATL in the native code to access your COM library. It might be a bit cumbersome (certainly not as easy as using COM from VB or even from .NET). So your first try should be at finding some Java/COM library, either commercial or on SourceForge, etc.

Flat View: This topic has 7 replies on 1 page
Topic: please help me........ Previous Topic   Next Topic Topic: Very simple question I am sure


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us