Home arrow static arrow Java Programming [Archive] - I really need ur help!!
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - I really need ur help!!
This topic has 15 replies on 2 pages.    1 | 2 | Next »

Posts:155
Registered: 6/9/03
I really need ur help!!  
Aug 4, 2004 10:32 AM



 
Hi,
my question is how to get the version number of a jar file from cvs in java code. I understand that we can use $Revision$ variables in our java code inorder to get the latest version generated by the CVS. But where should i put the $Revision$ tag such that this tag is replaced by the version corresponding to the jar file after CHECKIN. Some of you have suggested to use the properties file but i din't understand how would that solve my problem.

please refer to this link in case u din't follow my explanation
http://forum.java.sun.com/thread.jsp?forum=31&thread=542125

if not here. i don't know whom to ask abt this...
 

Posts:14,142
Registered: 99-04-02
Re: I really need ur help!!  
Aug 4, 2004 11:09 AM (reply 1 of 15)



 
I dont' think you can. Jars are binary files, and CVS doesn't? (shouldn't, I think) write anything into binary files, as this could possibly ruin them
 

Posts:2,206
Registered: 8/15/02
Re: I really need ur help!!  
Aug 4, 2004 11:15 AM (reply 2 of 15)



 
I concur. If you look at, say, xerces, they embed the version number in the jat and have methods to get the current version.
 

Posts:9
Registered: 8/4/04
Re: I really need ur help!!  
Aug 4, 2004 11:15 AM (reply 3 of 15)



 
Thats correct. The binary files shouldnt have any cvs related information written within it.
 

Posts:155
Registered: 6/9/03
Re: I really need ur help!!  
Aug 4, 2004 12:51 PM (reply 4 of 15)



 
Yeah! even i have observed that in the xcerces jar file in the MANIFEST.MF they have the version info.
But if we did so how could we possibly retrieve that version info?? so that we can display that version number somewhere in our application, say on applet.

But if the above is not possible there should be someother way to achieve this!!
 

Posts:2,206
Registered: 8/15/02
Re: I really need ur help!!  
Aug 4, 2004 12:56 PM (reply 5 of 15)



 
Well, here is how I get it from xerces - how you do it is up to you!
import org.apache.xerces.impl.Version;import java.lang.System;                                                                                                                                                                                                              public class xversion {                                                                                                                                                                                                                  public static void main(String [] argv) {        System.out.println("Xerces version: "+Version.fVersion);    }                                                                                                       }
 

Posts:14,142
Registered: 99-04-02
Re: I really need ur help!!  
Aug 4, 2004 1:16 PM (reply 6 of 15)



 
But that's (probably) not taken from the manifest file. I suppose one could use Ant and automate generating the manifest file from the version in the Version class... But it could just as likely be done manually.

Of course, if you have a Jar, you can use the java.util.zip/jar packages to open the Jar, get the manifest file and read the file to pull out the version number... if it's defined.
 

Posts:155
Registered: 6/9/03
Re: I really need ur help!!  
Aug 4, 2004 2:26 PM (reply 7 of 15)



 
i have defined an attribute in the Manifest.mft as below:

Main-Class: Lmeasure Name: $Revision$


since Name is also one of the attributes that can be specified in the manifest file.

and next, i have created a new jar file as below:

jar -cvmf Manifest.mft Lm1.jar *.class


and then, i have done CVS checkin of this new file Lm1.jar. Expecting that CVS would replace $Revision$ and henceforth i can retrieve the revision number using the java.util.jar package!!

But unfortunately, CVS is not replacing the $Revision$ tag in the Manifest.mft file!!

Therefore, what i understand from this is CVS will not interact with the files that are inside the jar file!!

back to square one situation :(

 

Posts:31,095
Registered: 4/30/99
Re: I really need ur help!!  
Aug 4, 2004 2:35 PM (reply 8 of 15)



 
Therefore, what i understand from this is CVS will not interact with the files that are inside the jar file!!

No, CVS will only set $Revision$ in what it understands to be text files. It treats jar files as binary (which they are), as mentioned in several replies above. To be more specific, "treating jar files as binary" means just writing them to and from the repository without doing anything else with them.
 

Posts:349
Registered: 1/8/04
Re: I really need ur help!!  
Aug 4, 2004 2:42 PM (reply 9 of 15)



 
It would be really simple if you just made sure that one file was updated every time you commit code changes.
 

Posts:155
Registered: 6/9/03
Re: I really need ur help!!  
Aug 4, 2004 3:02 PM (reply 10 of 15)



 
It would be really simple if you just made sure that one file was updated every time you commit code changes.

I agree, but when there are no changes made to the file how does the revision number get's updated. I mean even i make sure that a particular file gets updated everytime i make some changes, i don't think CVS will update the version number for that file becoz there are no changes made to it.
 

Posts:31,095
Registered: 4/30/99
Re: I really need ur help!!  
Aug 4, 2004 3:09 PM (reply 11 of 15)



 
Yes, you're right, you can't get good help these days. Give them simple instructions like "Before you produce a release, make a change to file X and put it back into CVS" and half the time they'll screw it up. Bring back the good old days I say.
 

Posts:155
Registered: 6/9/03
Re: I really need ur help!!  
Aug 4, 2004 3:20 PM (reply 12 of 15)



 
that's pretty dissappointing!!
so u think all these software releases (that which use CVS) doesn't show an accurate version release!!
 

Posts:2,206
Registered: 8/15/02
Re: I really need ur help!!  
Aug 4, 2004 3:20 PM (reply 13 of 15)



 
You could do cvs commit -f, which will force a new commit.
 

Posts:2,206
Registered: 8/15/02
Re: I really need ur help!!  
Aug 4, 2004 3:22 PM (reply 14 of 15)



 
Or indeed commit -r might also help you!
 
This topic has 15 replies on 2 pages.    1 | 2 | Next »