This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hope this is the right forum for this question. I have currently developed a java application which accepts xml as string & does xml to xml transformation using xsl After the input xml is transformed to the new xml we check if the new xml adheres to a DTD. In this java code i also uses log4j.
I have to create a jar file which has all the above mentioned artifacts. 1) All custom java code classes 2) log4j.jar, jaxp related jar files 3) log4j.properties 4) the XSL file which is used for transformation 5) The DTD to which the new xml confirms 6) a log file to which all logs are written.
I have created these above indivdual pieces & they work fine individually. But now i want to bundle all the above mentioned artifacts in a jar & place it into a content management system from where my classes will be invoked.
I dont have much experience with packaging of java related artifacts. I dont have any control over the system where this jar will be used so i have to bundle everything in the jar & use references to the xsl, dtd, log4j.properties files in such a way that it gets picked from the same jar i bundle all the artifacts.
So can someone give me some hints as to how can i pick the references to the xsl , dtd & log4j.properties in my java code from the jar file & not from the file system.
Currently for testing i use the file system reference & everything works fine.
Hi Manish, The JAR applications work on a common file, MANIFEST.MF or Meta-Inf file. This file defines the external Jars required, and the main-class entry. As i Have done in couple different broker applications, here is what you have to do: 1. If you have a class, that's initiating the whole parsing operation, then that would be your "Main-Class:" entry in Manifest.mf So, the class with a main method, that subsequently invokes the whole operation, should be there. 2. put your Jar files(e.g. log4j.jar) into one common folder, the folder in which your JAR application is going to run. 3.DTDs and all can reside into the same application folder. 4.build your classes 5.use "jar" tool, ported with your JDK from command prmpt to create an executable JAR. 6.put the Jar into the deplyment folder, where your log4j & accessories are residing. 7.run the application from command prompt/from shell-script
P.S. you can write an ANT script to do all this for you.
Thanks for the response. What I want to do is not keep the external files like xsl,dtd & log4j.properties in the folder where my application will run but want to package it in the same jar so the classes in the jar which require such external files will get it from the same jar.