Is there any way that i can give a version number to my application in netbeans.And then access that version number inside my code.
Something similar to the Assembly num
Define an Implementation-Version
in the manifest of the Jar at build time. It is common to use some form of the date as the version number. E.G. 14.07.28
The value can be retrieved in code using..
String version = this.getClass().getPackage().getImplementationVersion();
<tstamp>
<format property="now" pattern="yy.MM.dd"/>
</tstamp>
...
<jar
destfile="build/dist/lib/${jar.name}"
update='true'
index='true' >
<manifest>
<attribute name="Created-By" value="${vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Vendor-Id" value="org.pscode"/>
<!-- This next property is retrieved in code above. -->
<attribute name="Implementation-Version" value="${now}"/>
</manifest>
<fileset dir="build/share">
<include name="${package.name}/*.class" />
<include name="${package.name}/*.png" />
</fileset>
</jar>
This comes from a build file for a project I have open at the moment. The relevant attribute is the last one in the manifest section.
I don't know about .NET assembly numbers, but if you're creating a web application you can certainly put a version number into the manifest of your WAR file.
Any Java package can have a build info text file added to it so you can tell these things.
Your version number could be a build number from Ant, a version number from Subversion, or a combination of the two.
In my JavaFX app created in Netbeans, I can set the build version (Implementation version) in the Project Properties window shown here:
This number is then used everywhere, for example it is automatically inserted into the filename of the installer. It is also the number retrieved by this.getClass().getPackage().getImplementationVersion();
mentioned by the accepted answer.