Follow Me On...

Entries in Packaging (2)

Sunday
Oct292006

Java Packaging / Deployment Tools I Recently Came Across

These tools essentially take a jar and output a exe.  One of the things i hated about Java was if i created a simple utility which consisted of a single class (or jar) i still had to create a bat file which invoked the jre.  The end result being two files cluttering up my util bin folder on my computer.  These utilities take care of that and do a lot more like finding  appropriate jre and providing error messages to inform the user what they need to do.

  • jsmooth simple to use.
  • launch4j has a lot more features.

    Both are open source.

Another tool i came across but haven’t downloaded or tried yet is
IzPack  C which is a cross platform Installer written in Java.

Friday
Oct202006

VBS Script Code for File Versions

I had written build scripts for various products and the end result is typically some archive file (zip,msi,iso). My build scripts would create a file such as someproduct.zip but i wanted something todo someproduct-v2.x.x.zip.

That’s what the script below does.

' Author: Blake Robertson (10-21-06)
' 
' This script gets the file version of a particular file.  
' It then renames (or copies) the file with a versioned suffix.
' 
' Example: say test.EXE had a version of 2.1.95.0 and based on that you wanted
' to rename testPackage.zip to testPackage-v2.1.95.0"
'
' To do so, then set:
'    versionedFilePath = "test.exe"
'    nonversionedFilename = "testPackage.zip"
' 
' REQUIREMENTS: the original filename cannot have more then one '.' in it.' 
Dim versionedFilePath, nonversionedFilename, seperator

'### CUSTOMIZE THE FOLLOWING 3 LINES ###
versionedFilePath = "c:\path\to\exe"
nonversionedFilename = "c:\path\to\nonversioned\file.zip"
seperator = "-v"

Dim verStr, versionedFileName, filenameArr
Set FS = CreateObject("Scripting.FileSystemObject")
verStr = FS.GetFileVersion( versionedFilePath )

' Seperates filename from file extention
filenameArr = Split( nonversionedFilename, "." )

versionedFileName = filenameArr(0) & seperator & verStr & "." & filenameArr(1)

' Renames the Original File, if copy is desired then uncomment 2nd line and comment first
'FS.MoveFile nonVersionedFileName, versionedFileName
FS.CopyFile nonVersionedFileName, versionedFileName

If your project doesn’t create versioned executable files but you can obtain information from registry key or from a file, then replace the verStr = FS.GetFileVersion(…) line above with one of the snippets below:

Read Version Info in from a registry key:

verStr = WshShell.RegRead("HKLM\SOFTWARE\Your Company\Your Product\Version")

Snippet to read version info from a text file.

Set FS = CreateObject(“Scripting.FileSystemObject”)
verStr = FS.OpenTextFile(“version.txt”).ReadAll

Tip for SVN Users

If you are using SVN or some file versioning system, you can get version info by calling the update command twice. The second time redirect the output to a txt file. The second consecutive call to update will not update any files so the output should be just an informative version note.
svn update myCodeDir 
svn update myCodeDir > version.txt
type version.txt
At revision 342.