tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wade Chandler <>
Subject RE: Tomcat JNI Netbeans
Date Thu, 13 Sep 2007 02:29:42 GMT
You can load a native library directly using System.load instead of System.loadLibrary. All
have to do is figure out where the library is and be able to pass a full path to it. You can
the servlet API to get to your WEB-INF folder and get a full path to it. It is pretty trivial
there to make a System.load(fullPathToFile) call. 

You can also add extra options to Tomcat to set the Java library path. Depending on how you
Tomcat this can differ. For instance, you can set in a script for the user TC is run as, in
script you have which runs TC, or in catalina.bat/.sh an environment variable called JAVA_OPTS
part of this variable can be a list of directories for native libraries:
set JAVA_OPTS=-Djava.library.path="C:\somepath\somefolder;C:\someotherpath"


export JAVA_OPTS=-Djava.library.path="/somepath/somefolder:/someotherpath"


I didn't see the entire thread. Do you need to do something else specifically?


--- soulboy <> wrote:

> Thanks for the reply,
> > From: soulboy [] 
> > Subject: RE: Tomcat JNI Netbeans
> > 
> > > Does that work with JNI ?
> > JNI has nothing to do with Tomcat,
> Not sure what you mean by that.
> >  but rather with the JVM you're using.
> > For Sun-based JVMs, the location of native libraries must be specified
> > via the java.library.path system property.  When running on UNIX/Linux
> > platforms, the default value of that property is taken from the
> > LD_LIBRARY_PATH environment variable; for Windows, it comes from PATH.
> > The system property can alternatively be set directly on the launcher
> > command line.
> Yes I am aware of this.
> > Tomcat 6 uses a much simplified classloader hierarchy both to reduce
> > overhead and make certain operations easier, such as direct referencing
> > of Tomcat-specific classes.  Changing the classloader hierarchy to be
> > compatible with 5.5 or earlier is a step backwards.
> Ok well I take your word for it, I am new to Java so I am sure you are right
> but it doesnt mean much to me.
> > > All the instructions for JNI with Tomcat say use
> > > $CATALINA_HOME/shared/lib.
> > What instructions are those?  If they're coming from some 3rd party,
> > they're out of date (not unusual).
> Yes you are probably right however do you know where there are any official
> instructions on setting up JNI and Tomcat ? 
> > Also I would prefer to keep my jars separately 
> > as its easier to keep track of things.
> > Which is why the servlet spec recommends that webapps be implemented
> > independently, and jars should go into WEB-INF/lib of each webapp, even
> > if that means duplicating them.  Since you're insisting on using JNI
> > (thereby guaranteeing your app is not portable), you're stuck with the
> Actually for this project portability isnt important but being able to call
> third party DLLs is. If it wasnt for JNI we couldnt use Java. I wouldnt
> be surprised if this keeps cropping up.
> > Java restriction that a native library can only be loaded once,
> > regardless of the number of classloaders that want to use it.  I'd still
> > put the common jar in Tomcat's lib directory, since that's simple and
> > straightforward.
> Ok thanks again
> -- 
> View this message in context:
> Sent from the Tomcat - User mailing list archive at
> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message