@echo off
setlocal

set bin=%~dp0
set lib=%bin%\..\lib

set jars=%lib%\w2x_rt.jar;%lib%\saxon.jar;%lib%\xmlresolver.jar;%lib%\whc.jar;%lib%\snowball.jar

if not exist "%lib%\wmf_converter.jar" goto skipwmf
set jars=%jars%;%lib%\wmf_converter.jar;%lib%\wmf2svg.jar
:skipwmf

if exist "%lib%\w2x.jar" goto usejar
set cp=%bin%\..\class;%jars%
goto setjre
:usejar
set cp=%lib%\w2x.jar;%jars%
:setjre

if not exist "%lib%\emf2png.jar" goto skipemf
set cp=%cp%;%lib%\emf2png.jar
:skipemf

if exist "%bin%\jre64\bin\java.exe" goto privatejre
set java=java
goto run
:privatejre
set java=%bin%\jre64\bin\java.exe
:run

"%java%" -DW2X_TRACE="%W2X_TRACE%" -DW2X_IMAGE_CONVERSIONS="%W2X_IMAGE_CONVERSIONS%" -DW2X_MATH_CONVERTER_XSLT="%W2X_MATH_CONVERTER_XSLT%" -Djava.awt.headless=true -Djava.library.path="%lib%" -classpath "%cp%" com.xmlmind.w2x.processor.Start %*
