Resource Bundles outside of JARs

Discussion in 'Java' started by success_ny@yahoo.com, Mar 17, 2005.

  1. Guest

    I would like to package my Java application (executable, not J2EE or
    web) in a JAR and not package my resource bundle properties file in a
    JAR. My reasoning is as follows: one of the reasons I use resource
    bundle as a .properties file is that it makes it easy to make changes
    to certain properties dynamically at run-time without recompiling the
    application. Especially if the application is in production, any
    changes to the JAR would be complicated. So, ideally I would like my
    resouce bundle properties file to reside separately from the JAR where
    the code is packaged so I can change, say, flag settings (like, enable
    debugging at run-time) or make other changes without touching the JAR.
    Does it make sense? How do I load Resource Bundle if it just resides on
    the file system and is not part of JAR efficiently?

    Thank you!
    , Mar 17, 2005
    #1
    1. Advertising

  2. Oscar kind Guest

    wrote:
    > I would like to package my Java application (executable, not J2EE or
    > web) in a JAR and not package my resource bundle properties file in a
    > JAR.


    This is not difficult. Resources don't have to be in a .jar file; they
    just have to be in the classpath. Add a Class-Path header to the manifest
    for ".", and the resource files may also be located in th same directory
    as the .jar file.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
    Oscar kind, Mar 17, 2005
    #2
    1. Advertising

  3. you can add an entry like
    [---]
    Class-Path: .
    [---]
    to the manifest file of your jar and put the property-files in the folder
    you started the jar from.
    This is equivalent to starting your jar with the option "-classpath .".


    <> schrieb im Newsbeitrag
    news:...
    >I would like to package my Java application (executable, not J2EE or
    > web) in a JAR and not package my resource bundle properties file in a
    > JAR. My reasoning is as follows: one of the reasons I use resource
    > bundle as a .properties file is that it makes it easy to make changes
    > to certain properties dynamically at run-time without recompiling the
    > application. Especially if the application is in production, any
    > changes to the JAR would be complicated. So, ideally I would like my
    > resouce bundle properties file to reside separately from the JAR where
    > the code is packaged so I can change, say, flag settings (like, enable
    > debugging at run-time) or make other changes without touching the JAR.
    > Does it make sense? How do I load Resource Bundle if it just resides on
    > the file system and is not part of JAR efficiently?
    >
    > Thank you!
    >
    Ferenc Hechler, Mar 17, 2005
    #3
  4. Oscar kind Guest

    Ferenc Hechler <> wrote:

    > This is equivalent to starting your jar with the option "-classpath .".


    Alas, this is not generally true: when you start a .jar file with the -jar
    switch, any classpath settings outside the .jar file are ignored.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
    Oscar kind, Mar 18, 2005
    #4
  5. Guest

    So let me make my question specific and clear: if I call my java
    program from a command line supplying CLASSPATH like this (on Unix):

    CLASSPATH=.:$CLASSPATH:$JARS_HOME:$JARS_HOME/j2ee.jar:MyApp.jar
    java -classpath com.blah.MainProgram

    Then I can put the myResources.properties file in that same JARS_HOME
    directory and call it from the Java like this:

    myResourceBundle = ResourceBundle.getBundle("myResources",
    Locale.ENGLISH);

    That does not work!

    Any ideas how to make it work?
    , Mar 23, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M Series
    Replies:
    0
    Views:
    352
    M Series
    Oct 20, 2003
  2. Replies:
    0
    Views:
    400
  3. pojo

    resource bundles...

    pojo, Feb 22, 2006, in forum: Java
    Replies:
    1
    Views:
    915
    Rhino
    Feb 22, 2006
  4. enrique

    Why resource bundles

    enrique, Apr 17, 2007, in forum: Java
    Replies:
    1
    Views:
    342
    Wojtek
    Apr 17, 2007
  5. Marco

    cross-jars resource bundles

    Marco, Oct 13, 2009, in forum: Java
    Replies:
    4
    Views:
    727
    Roedy Green
    Oct 14, 2009
Loading...

Share This Page