• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

package jar question

 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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.

Do post your suggestions for the same


Regards
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

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.

Do post your thoughts
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic