Static and final variables

Discussion in 'Java' started by Arinté, Jun 14, 2005.

  1. Arinté

    Arinté Guest

    I have this situation.
    I have several jar files and each jar file has a separate version.
    util.jar
    Version.java

    XMt.jar
    Version.java

    XSlT.jar
    Version.java

    All the jar files references to and uses util.jar. Instead of constantly
    having to update each Version.java file
    I would like to have them refer to the number that is set in util.jar. For
    example

    in XMt.jar
    Version.java
    VERSION_NUMBER = util.jar.XMt.Version.

    So basically these numbers need to be written at compile time just in case a
    user mixes the jar files I want to be able to know when each jar was built
    and not just the current version of the util.jar.

    Any solutions?
    Should this work if I used public static final?
    Arinté, Jun 14, 2005
    #1
    1. Advertising

  2. Nope, that won't work. You're just referring to another reference to a
    memory location.

    Try using a version control system and let it substitute a literal for you
    in each Version.java instead.

    Regards,
    Christian
    Christian Schlichtherle, Jun 15, 2005
    #2
    1. Advertising

  3. Arinté

    Wibble Guest

    Arinté wrote:
    > I have this situation.
    > I have several jar files and each jar file has a separate version.
    > util.jar
    > Version.java
    >
    > XMt.jar
    > Version.java
    >
    > XSlT.jar
    > Version.java
    >
    > All the jar files references to and uses util.jar. Instead of constantly
    > having to update each Version.java file
    > I would like to have them refer to the number that is set in util.jar. For
    > example
    >
    > in XMt.jar
    > Version.java
    > VERSION_NUMBER = util.jar.XMt.Version.
    >
    > So basically these numbers need to be written at compile time just in case a
    > user mixes the jar files I want to be able to know when each jar was built
    > and not just the current version of the util.jar.
    >
    > Any solutions?
    > Should this work if I used public static final?
    >
    >

    Instead of creating:

    class Util { public final static int VERSION=1.2; }

    use:

    class Util { public final static int VERSION_1_2 = 0; }

    and refer to the named symbol, not the value to ensure that the jars are
    compatible.
    Wibble, Jun 15, 2005
    #3
    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. Replies:
    1
    Views:
    933
  2. SaravanaKumar
    Replies:
    6
    Views:
    9,395
    Tony Morris
    Oct 19, 2004
  3. JFCM
    Replies:
    4
    Views:
    5,734
  4. Replies:
    5
    Views:
    513
    Chris Uppal
    Nov 17, 2006
  5. Ricardo Palomares Martinez
    Replies:
    2
    Views:
    376
    david.karr
    Apr 28, 2007
Loading...

Share This Page