Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Static and final variables

Reply
Thread Tools

Static and final variables

 
 
Arinté
Guest
Posts: n/a
 
      06-14-2005
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?


 
Reply With Quote
 
 
 
 
Christian Schlichtherle
Guest
Posts: n/a
 
      06-15-2005
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


 
Reply With Quote
 
 
 
 
Wibble
Guest
Posts: n/a
 
      06-15-2005
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any sense in using private static final for non-static classes? Ricardo Palomares Martinez Java 2 04-28-2007 10:45 PM
Word open as Final, not Final Showing Markup Karl Engel Computer Support 4 12-19-2006 04:20 AM
Non-final class at compile-time, final at runtime pietdejong@gmail.com Java 5 11-17-2006 12:30 PM
Difference between static final members and final static members(if any)? JFCM Java 4 02-07-2006 11:32 AM
Instantiating a static class( Class with all static members - methods and variables) SaravanaKumar Java 6 10-19-2004 08:20 AM



Advertisments