Developers, Developers, Developers! Maksim Sorokin IT Blog


Discovering Version of Java in a BAT File

Sometimes in a BAT file we need to know what Java version are we running -- is it 32bit or 64bit. Here is a sample bat file, which depending on a Java version uses different native library directory:

@echo off

:: At this point you can place assumptions about Java version. It is still better than nothing anyway. In this particular case, we rely on a knowledge of Java version during installation time (with IzPack). Or you can just specify default value here, for example by default assume that 32 version is being run
if $SYSTEM_os_arch==x86 (
  set JVM_VERSION=32
) else (
  set JVM_VERSION=64
:: End of assumption section

:: Now trying to find out, what is current jvm version.

set TEMP_FILE=%TEMP%\javaCheck%RANDOM%%TIME:~9,5%.txt

java -version 2>%TEMP_FILE%
FOR /F "tokens=*" %%i in (%TEMP_FILE%) do (
  echo %%i | find "HotSpot" >nul
  if not errorlevel 1 (
    echo %%i | find "64-Bit" >nul
    if not errorlevel 1 (
      set JVM_VERSION=64
    ) else (
      set JVM_VERSION=32


if %JVM_VERSION%==32 (
) else (

start "App" javaw -classpath .;"%NATIVE_JARS%/*"

The trick is to redirect java -version to a temporary file. Then try to find a line with "HotSpot" substring. If that line contains "64-Bit", then it is 64bit version Java. Otherwise it is 32bit.


IzPack: Thoughts on Using Environmental Variables in Silent Installation

IzPack is pretty powerful installation tool. However, silent installation (or the call it Automated Installers) lacks some flexibility. One of the things, which I lack, is a possibility to provide environmental variables in silent installation configuration files (auto-install.xml). Here I will provide some tricks which would help making your installer "eat" silent installation configuration files with environmental variables.

To start with,


Modularized Installers with IzPack

link to dependency plugin

One may want to modularize installer's components and support them separately. It is easy to do with IzPack too!
In this example, we suppose, that installers are built with Maven.

Ok, now we


Backuping Files with BAT

When I need to backup a file in my bat script, I usually do like this:

copy /Y fileToBackup fileToBackup.bak_%date%_%time:~0,2%%time:~3,2%

Which gives a nice timestamp in the filename, for example:

Tagged as: , Comments Off

Two Ways of Running Executables in Izpack

There are two ways to run executable files in IzPack. The first one is


Installation with IzPack — Launching BAT Files

Intuitively we know -- if we can run a bat file.. we can probably to everything. And yes, you can run bat files from IzPack too!
I will assume, that you read my previous post about simple IzPack + Maven applications. In order to run a bat file, we will have to use a IzPack ProcessPanel.

In your install.xml you need to


Simple Variable Substitution in BAT Files

From set command reference:
>> Environment variable substitution has been enhanced as follows:
>> %PATH:str1=str2%

For example you can change the backslashes to slashes in the URL parameter when you pass it to the Java file:

echo %resources.home:\=/%
Tagged as: Comments Off