How to load DLL files in a tomcat-based Web project (from actual project experience)

Source: Internet
Author: User

If it is a Java project, you only need to put the DLL in SRC and set the run configuration. However, in a web project (according to the relevant data, 60% of users use Tomcat ), in this way, the DLL cannot be loaded at all.

There are always methods. The key is how to make system. loadlibrary ("testdll"); find the correct path. The following is my summary (I tried a lot of methods, but I can't do it. There are only 100% rows in this method ).

This method is:

Open the bin directory in the directory where your Tomcat is located. My directory is c: \ apache-Tomcat-7.0.6 \ bin and copy the DLL file to it.

In this way, you can run system. loadlibrary ("testdll") in the web project, and no unsatisfiedlinkerror will be reported.

 

However, an exception was reported when the server was actually deployed. I was quite depressed and later found that there were some other servers except tomcat.Program, That is, Tomcat is wrapped in a layer. Although Tomcat is started when the server is started, Tomcat is not the main program.

So I put the DLL file in the directory of startup. bat of the server, and the DLL is loaded successfully.

Based on this practice, I have summarized it into one sentence:

Find the directory where the main program runs (most of which are bin, except which may be packaged) and copy the DLL file. 100% run system. loadlibrary ("testdll.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.