tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Schönhaber <>
Subject Re: How can I modify the java.library.path in Tomcat?
Date Sat, 03 Jun 2006 08:18:10 GMT
Andi Heusser wrote:
> I have a web application where I need to load some 3rd party libraries
> DLLs) and I would like to have these DLLs in a subdirectory in my app
> (webapps/MyApp/WEB-INF/lib). However when I try to do a 'loadLibrary' it
> fails to find them. I then noticed that the 'Tomcat/bin' directory is in
> this path and if I copy the DLLs in there, then it works fine.
> I've tried to set the system property inside my app in the static
> initializer of the main class but that doesn't seem to work. I basically
> tried to do the following:
>       static{
>             String libPath = System.getProperty("java.library.path");
>             String myLibPath = System.getProperty("myapp.lib.path");
> //env var set in PC's system variables (WinXP)
>             System.setProperty("java.library.path", libPath +
> File.pathSeparator + myLibPath);
>       }

This is not Tomcat specific. java.library.path is readonly, so this won't 
work. You'll have to set the property on startup of the JVM, i. e. 
add -Djava.library.path=<your path> to the JVM's arguments.

> I also looked through the Tomcat conf files but I couldn't find any place
> where I could properly set or override the java.library.path.
> Is there a way to set this in Tomcat or will I have to copy the DLLs into
> Tomcat's bin directory?

If you start Tomcat with the shell scripts, you can create a file named (resp. setenv.bat on Windows) where JAVA_OPTS is set appropriately. 
If you use the service launcher, you'll have to define this somewhere in the 


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

View raw message