diff --git a/bin/dispatcher b/bin/dispatcher
index 649e30f..06d19db 100755
--- a/bin/dispatcher
+++ b/bin/dispatcher
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
ROOT="$(pwd)"
-VERSION="1.2.1"
+VERSION="1.2.2"
cd "$(dirname "$0")" || exit
cd "../"
# Navigate to the root directory
@@ -15,7 +15,8 @@ args=""
# Loop through each argument
for arg; do
# Extract the first two characters of the argument
- str=${arg:0:2}
+ # str=${arg:0:2}
+ str=$(echo "$arg" | awk '{ string=substr($0, 0, 2); print string; }' )
# Check if it starts with '-D' or '-X'
if [ "$str" = "-D" ] || [ "$str" = "-X" ]; then
diff --git a/bin/dispatcher.cmd b/bin/dispatcher.cmd
index e549522..dd62a76 100755
--- a/bin/dispatcher.cmd
+++ b/bin/dispatcher.cmd
@@ -1,5 +1,5 @@
@rem ***************************************************************************
-@rem Copyright (c) 2017 James Mover Zhou
+@rem Copyright (c) 2023 James Mover Zhou
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@@ -14,7 +14,27 @@
@rem limitations under the License.
@rem ***************************************************************************
@echo off
+
+@REM Check if JAVA_HOME is set and valid
+if "%JAVA_HOME%" == "" (
+ echo Error: JAVA_HOME not found in your environment. >&2
+ echo Please set the JAVA_HOME variable in your environment to match the location of your Java installation. >&2
+ exit /B 1
+)
+
+if not exist "%JAVA_HOME%\bin\java.exe" (
+ echo Error: JAVA_HOME is set to an invalid directory. >&2
+ echo JAVA_HOME = "%JAVA_HOME%" >&2
+ echo Please set the JAVA_HOME variable in your environment to match the location of your Java installation. >&2
+ exit /B 1
+)
+
+set "JAVA_CMD=%JAVA_HOME%\bin\java.exe"
+
+@REM Consolidate classpath entries, initialize ROOT and VERSION
set "ROOT=%~dp0..\"
-set "VERSION=1.2.1"
-set "classpath=%ROOT%target\classes:%ROOT%lib\*:%ROOT%WEB-INF\lib\*:%ROOT%WEB-INF\classes":%classpath%
-@java -cp "%ROOT%target\classes;%ROOT%lib\tinystruct-%VERSION%-jar-with-dependencies.jar;%ROOT%lib\*;%ROOT%WEB-INF\lib\*;%ROOT%WEB-INF\classes;%USERPROFILE%\.m2\repository\org\tinystruct\tinystruct\%VERSION%\tinystruct-%VERSION%-jar-with-dependencies.jar" org.tinystruct.system.Dispatcher %*
\ No newline at end of file
+set "VERSION=1.2.2"
+set "classpath=%ROOT%target\classes;%ROOT%lib\tinystruct-%VERSION%-jar-with-dependencies.jar;%ROOT%lib\*;%ROOT%WEB-INF\lib\*;%ROOT%WEB-INF\classes;%USERPROFILE%\.m2\repository\org\tinystruct\tinystruct\%VERSION%\tinystruct-%VERSION%-jar-with-dependencies.jar"
+
+@REM Run Java application
+%JAVA_CMD% -cp "%classpath%" org.tinystruct.system.Dispatcher %*
diff --git a/pom.xml b/pom.xml
index b3e5f23..d22ae5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
org.tinystruct
tinystruct
- 1.2.1
+ 1.2.2