accessing dlls using a jni in tomcat

I

ian ward

Hello,
I have some dlls and a corresponding set of jni classes which are part
of my jar which I want to run as a web server in tomcat. I think that
the jar is in the right place (webapps\myapp\WEB-INF\lib) but I'm not
sure where I need to put the dlls. Up to now, while developing/testing
outside of tomcat I have put the jar and the dlls in the same folder
but that doesn't seem to do it. I may have to set some sort of system
variable like path (which I understand is the java.library.path under
windows (xp)). I have tried this but again no joy.

Strangely, I got the thing working for a while, don't know how (moving
files around etc), but that seems to have been a flash in the pan. I'm
trying to launch the jar from a jsp page, via a useBean action and I
get a 'page can't be displayed' message and tomcat crashes and I have
to restart so I don't get any help.

I'm starting to get to the hair-tearing stage so any help, pointers,
suggestions would be very welcome.
Thanks
Ian
 
A

Alan Krueger

ian said:
I have some dlls and a corresponding set of jni classes which are part
of my jar which I want to run as a web server in tomcat. I think that
the jar is in the right place (webapps\myapp\WEB-INF\lib) but I'm not
sure where I need to put the dlls.

Just put them somewhere in the Windows PATH. You'll need to reboot
Windows if you change the PATH environment variable and have Tomcat
launched as a service, since the Service Control Manager doesn't appear
to reload environment variables until it's restarted, which can't (IIRC)
be done without rebooting the entire operating system.

Also, you may want to put the JNI Java classes into Tomcat's common/lib
directory if you want to use these JNI classes in more than one web
application. Otherwise, they might be loaded using separate class
loaders and any after the first load will fail.
 
I

ian ward

Thanks for the reply.

I have tried putting them in windows\system32 (but I suppose any folder
will do provided it's quoted in the path). This didn't seem to work but
I'll try again, I haven't always had 100% success with PATH.

So I don't need to worry about what the "working directory" is?

Haven't quite followed your reasoning on relaunching as a service etc.
Anyhow, if I can fix it, then restarting the OS is not very serious -
once it's fixed it's fixed, no?

For the JNI classes, I'm not intending to have them in common so I
suppose it doesn't really matter that I haven't understood your remark
about separate class loaders and failing loads!

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top