Static and final variables

A

Arinté

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?
 
C

Christian Schlichtherle

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
 
W

Wibble

Arinté said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top