ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » loadlibrary location

Post new topic  Reply to topic Goto page Previous  1, 2
 loadlibrary location « View previous topic :: View next topic » 
Author Message
bobbee
PostPosted: Fri Mar 13, 2015 7:32 am    Post subject: Reply with quote

Knight

Joined: 20 Sep 2001
Posts: 547
Location: Tampa

Just keeping the dream alive

So this:

public class HelloWorld {
native void helloFromC();
static {
System.load("C:\\IIBShared\\ctest.dll");
/* System.loadLibrary("ctest.dll"); */
/* System.loadLibrary("ctest"); */
}
public static String compress() {
HelloWorld helloWorld = new HelloWorld();
helloWorld.helloFromC();
return "1";
}
}

Got me this:

Text:CHARACTER:Java class not found
Insert
Type:INTEGER:5
Text:CHARACTER:com.cbs.common.HelloWorld.compress
Back to top
View user's profile Send private message Send e-mail AIM Address
fjb_saper
PostPosted: Fri Mar 13, 2015 8:15 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20768
Location: LI,NY

bizzarre... My stand alone JMS has no problem with this:

Code:
   private String module = "C:/MQ/MQ8/Tools/c/samples/mqccred/bin/mqccred.dll";
   private String module64 = "C:/MQ/MQ8/Tools/c/samples/mqccred/bin64/mqccred.dll";

.......
         String procversion = System.getProperty("sun.arch.data.model");
         if (load){
            if ("32".equals(procversion)){
               System.load(module);
            } else if ("64".equals(procversion)){
               System.load(module64);
            }

         }

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Fri Mar 13, 2015 8:20 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20768
Location: LI,NY

bobbee wrote:
you made a statement that has me questioning what I am doing. I have a single C program named ctext. yet you say this:

a C library that has the JNI interface and calls correctly into the existing C library (Which in all likelihood did not have any JNI calls pre-configured.

So it seems you are saying two C programs. I don't get this from the instructions.


Well it is as simple as this. You want to call a C function from JNI.
Look at the jni call to make, look at the interface it generates.
If the interface does not exist in C you need to create a "pass through" handle. i.e. called from JNI calling the C interface I need to talk to...
If you know what the interfaces are it should not be too complicated yes?

Assumptions
  • leaving the original C program / library untouched
  • java signature something like: native String funcname(String mystring)
  • original c signature string* funcname (string *)
  • jni signature JNIEXPORT jString * JNICALL Java_funcname
    (JNIEnv * env, jObject jobj, jString * mystring)

So you need a way to translate the JNI call to the C native call, unless the original library already takes care of that, which I doubt....

A few more examples and better explanation: http://en.wikipedia.org/wiki/Java_Native_Interface

And then there is the whole JNA (java native access) project school...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
tczielke
PostPosted: Fri Mar 13, 2015 9:40 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 943
Location: Illinois, USA

For your process address space that is trying to load the dll, are you possibly mixing a 64 bit address space with a 32 bit dll or vice versa?

Also, the SysInternals ProcMon could be helpful here. If you recreate your issue with ProcMon, it should show you all the underlying open calls that are being made to find/open your dll and potentially the underlying issue.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
bobbee
PostPosted: Fri Mar 13, 2015 9:50 am    Post subject: Reply with quote

Knight

Joined: 20 Sep 2001
Posts: 547
Location: Tampa

Thanks for the links to JNI programming. Will read

I tried the LD path, i added the directory to the PATH statement and I just tried the code above with System.Load. none of it worked. I will read the links and see what is going on. I know the load is not working. Why, I do not know.
Back to top
View user's profile Send private message Send e-mail AIM Address
fjb_saper
PostPosted: Fri Mar 13, 2015 10:38 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20768
Location: LI,NY

Also be careful. You can load the module as many times as you want without error.... so I suggest you use some kind of method that checks if it is already loaded and bypasses the load if it already is... and make sure to synchronize it...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » loadlibrary location
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.