Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

Static and final variables

Thread view: 
Arinté - 14 Jun 2005 22:39 GMT
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?
Christian Schlichtherle - 15 Jun 2005 01:09 GMT
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
Wibble - 15 Jun 2005 02:56 GMT
> I have this situation.
> I have several jar files and each jar file has a separate version.
[quoted text clipped - 22 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.