[RC3] Java 7 on Windows --- sikuli-script.jar with temporary fix

Created by RaiMan on on 2012-05-09
Keywords:
Last updated by:
RaiMan on on 2013-05-18

The current version of Sikuli for Windows (X-1.0 - r 905 and r930) crashes with Java 7, when you try to interactively capture an image.

The cause of the problem is Sikuli's handling of transparent windows/frames, which is tailored to Java 6. The API has changed with Java 7: the feature is now integrated and no longer in AWTUtilities.

A fix is a bit more complicated, since the same Sikuli should work with Java 6 AND Java 7.

As a workaround I have made a sikuli-script.jar, that works with Java 7 only:
http://dl.dropbox.com/u/42895525/sikuli-script-java7.zip

The zip contains a README. Use at your own risk.

******* steps to get it working

It is supposed, that you use the standard places for Sikuli. and JRE6/JRE7 (standard Program Folder).
If this is not the case, you have to adapt the steps and the command file accordingly.
Be aware: you still need a JRE 32-Bit.

1. purge any references to any Sikuli stuff from your environment (PATH, CLASSPATH, Variables, ...)

2. remove the entry ….jre6\bin from PATH (no longer needed for Sikuli with Java 7)

3. download the r930 stuff (http://sikuli.org/download.shtml - Windows section)
and replace the content of Sikuli X with the content of Sikuli-IDE from the unzipped r930

4. rename sikuli-script,jar to e.g. sikuli-script-java6.jar (as a backup)

5. copy the sikuli-script.jar (Java 7 workaround version) as sikuli-script.jar (MUST be this name) into the folder Sikuli X

6. use the following command file to start and use the IDE
This command file can be used in the same way as the Sikuli-IDE.bat, but does not need any environment preparations.

rem --- content of the command file (Windows 32Bit)
@echo off
setlocal
set SIKULI_HOME=%PROGRAMFILES%\Sikuli X\
set JAVADIR=%PROGRAMFILES%\Java\jre7\bin
set PATH=%SIKULI_HOME%libs;%PATH%
set SIKULI_SCRIPT=%SIKULI_HOME%sikuli-script.jar
set SIKULI_IDE=%SIKULI_HOME%sikuli-ide.jar
set SIKULI_IDE_PARM=-Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%SIKULI_SCRIPT%/"
"%JAVADIR%\java.exe" %SIKULI_IDE_PARM% -jar "%SIKULI_IDE%" %*
endlocal
rem --- content of the command file

rem --- content of the command file (Windows 64Bit)
@echo off
setlocal
set SIKULI_HOME=%PROGRAMFILES(X86)%\Sikuli X\
set JAVADIR=%PROGRAMFILES(X86)%\Java\jre7\bin
set PATH=%SIKULI_HOME%libs;%PATH%
set SIKULI_SCRIPT=%SIKULI_HOME%sikuli-script.jar
set SIKULI_IDE=%SIKULI_HOME%sikuli-ide.jar
set SIKULI_IDE_PARM=-Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%SIKULI_SCRIPT%/"
"%JAVADIR%\java.exe" %SIKULI_IDE_PARM% -jar "%SIKULI_IDE%" %*
endlocal
rem --- content of the command file

If you want to have the behavior of Sikuli-IDE-w.bat, replace the line
"%JAVADIR%\java.exe" %SIKULI_IDE_PARM% -jar "%SIKULI_IDE%" %*

with
start /B "Sikuli-IDE" "%JAVADIR%\javaw.exe" %SIKULI_IDE_PARM% -jar "%SIKULI_IDE%" %*

Feel free to adapt this command file to anything else you need (e.g. run sikuli-script.jar, use Jython directly, ...)