• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Adding jndi.properties to 'Class-Path:' in generated jar file

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

I am trying to generate a jar file in Maven2 with a jndi.properties file included the Class-Path manifest attribute. The Class-Path attribute also needs to reference all the dependent jar files (which I am currently doing using <addClasspath>true</addClasspath> , but I can't seem to get both.

Is there a way to do this using Maven?
 
J Rosetto
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note, the reason I want to do it like this, rather than putting it into /resources (which will package it into my jar), is that I want to keep the jndi.properties outside my jar file so that it can be easily edited.
 
Saloon Keeper
Posts: 28125
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if I read that correctly, but here's a stab:

If you produce an executable JAR, all the resources (classes, property files, images, etc.) in that JAR will be placed in the app's CLASSPATH when you run the jar with the "java -jar jarfile" option.

Libraries, however, will not. They'll be visible on the classpath, but the app can't load or use their contents.

Fortunately, someone - or maybe several someones - have realized that this is a problem and that Maven can fix it. I haven't yet got the process all worked out, but apparently there's a Maven plug-in that can cause a custom classloader to be integrated into your app that peers inside the JARS and adds their contents to the classpath.
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic