By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,841 Members | 854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,841 IT Pros & Developers. It's quick & easy.

Using dll and .conf files in java web application

P: 5
Hi all,

I am using netbeans as IDE and glassfish as app server for my web application.
At runtime it needs some dll files and .conf file. Now the question is:
1. How should I package the .conf file into my web application war file. The scenario is that one .conf file makes use of another. e.g. if one file is a.conf and another is b.conf then the path of b.con is specified in a.conf as absolute path. How I have to change this path in case I will bundle it in my war file.
2. How can i configure app server or netbeans so that the dll files will be available at runtime to the application.

This is really urgent as I am stuck on it.

Apr 6 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 785
1.) don't hardcode any absolute path! You can always get the current directory where your application started. In your case you can get the directory where you deployed the war-file with
Expand|Select|Wrap|Line Numbers
  1. servletContext.getRealPath("/").
If you use relative path only then referencing to one file inside another is no problem. For example I use an entry in web.xml to reference to an .xsl file I need for transformation:
Expand|Select|Wrap|Line Numbers
  1.     ServletContext servletContext = request.getSession().getServletContext();
  2.     String xslFile= servletContext.getInitParameter("xslFile"); // e.g. "/xslFiles/myFile.xsl"
  3.     String xslFilePath = servletContext.getRealPath(xslFile) ; // e.g. "C:/Tomcat/webapps/ROOT/myApp/WEB-INF/xslFiles/myFile.xsl
2.) don't use *.dll files. Just get the corresponding *.jar file. Dll-files are platform dependent and only run on Microsoft Windows. If you access functions in dll-files through native calls in java (or whatever you do with the dll-files, I am really wondering about that), you need to provide the corresponding files for EVERY platform. For example corresponding *.so files for Linux, Mac-OS, AIX, HP-UX, Solaris and others. For each of these platforms, you need to provide your own platform-dependent installer. (For example InstallShield on Windows that copies your dll-files into the win32-directory). That's a lot of work and possibly not a good idea, so avoid *.dlls and use *.jar files instead, which can be easily deployed, no matter what operating system you are using. (Just put them into lib-directory or add them to your classpath)
Apr 7 '09 #2

P: 5
Hi chaarmann,

Thanks for the reply.

Suppose I put my A.conf file under WEB-INF/classes/config folder which refers to B.conf file in the same folder should I change the path to B.conf as /config/B.conf.

Regarding dll files, these are some tool specific files that needs to be used and these are to be used only on Windows platform so can you please tell me where should I put it in my web application so that these are available to my application at runtime.

Apr 7 '09 #3

Expert 100+
P: 785
That could work. But most likely it's "classes/config/B.conf". (see comments in my code example above).
To make sure just print out the path you get (system.out.println(servletContext.getRealPath("/")), it should be "WEB-INF/classes" in your case, then you know what to append to it.

See above, I already suggested to use something like InstallShield, so users can easily deinstall.
But if it's only for yourself, just copy the dlls into the directory "system32" inside your windows-directory, where all the other dlls are.
Apr 7 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.