• 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

JavaFX About dialog

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using NetBeans to develop a JavaFX application and would like to add an About dialog to report the application version with a build number but do not know how to capture the buildnumber so that I can query it at runtime.

Any help would be very welcome!
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

The basic idea is to have a properties file with the version number in your src or resources directory, so that it gets bundled along with the application JAR and can be read by your dialog or other code.
The version number in that properties file is updated on each build by whatever build system you're using.
Since you mention netbeans, this article describes how to do it in Netbeans by editing the ant build file.
 
Sarah Dixon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added a properties file to my package

Application.Version = 1.0.${Application.buildnumber}


and modified the nbproject/buil-impl.xml file to include the following in the "-post-jar" target:

<propertyfile file="${src.dir}/MyJavaFXAppname/MyJavaFxAppname.properties">
<entry key="Application.buildnumber" value="1" type="int" operation="+"/>
</propertyfile>

The properties file gets updated by the build but I have not been able to figure out how to reference this properties file in my Java code. I am thinking that at runtime it should either be in the project folder or the dist folder but the build is not putting it in either place.


 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be inside the application JAR file. Open the JAR file with some unzip utility, and you should have it there.

For reading it, use
 
Sarah Dixon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That did it. Thank you!
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic