Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaFX About dialog

 
Sarah Dixon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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!
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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
  • 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 C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
That did it. Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic