• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to store compile time data in Java

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
Is there any way to store compile time data in Java?
For example I want to compile one class which displays today's date and time. I am using Calender class to do this.
And This today's date is displayed in About box of my application.
But what is happening is if I open my application 4 days from now it displays the date current on that day and not today's date when I compiled my application.
I know all objects are created at runtime in Java.
But was interested does any one knows a trick on how to do this.
Thanks
Avinash.
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, just a thought off the top of my head... there's probably a better way of doing it...
Your build process could include the execution of a java program that generates another java class that stores the compile time date. For example, the program would use a PrintWriter to actually write a java source file that contains a static constant that is initialized with the current date. Like this:

Your build routine can compile the new HelpInfo source file and include it in your release. Then, your "About" frame could get the compile date via HelpInfo.COMPILE_DATE.
Good luck!
[ October 16, 2002: Message edited by: Blake Minghelli ]
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a similar idea, why not have a properties file that is generated by your build process that has a timestamp in it,
Then you can just use that pre-defined property as the source of your "about box"
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic