This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-108
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-108 by this push:
     new 894889f  WIP.
894889f is described below

commit 894889f6fc775667f78e8430e2f45f1fb13e3762
Author: Aaron Radzinski <[email protected]>
AuthorDate: Thu Aug 27 12:04:14 2020 -0700

    WIP.
---
 bin/nlpcraft.cmd | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 bin/nlpcraft.sh  |  3 ++-
 2 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/bin/nlpcraft.cmd b/bin/nlpcraft.cmd
index bf4e940..46f40d3 100644
--- a/bin/nlpcraft.cmd
+++ b/bin/nlpcraft.cmd
@@ -15,5 +15,84 @@
 :: limitations under the License.
 ::
 
-@echo OFF
+@echo off
 
+::
+:: Following several functions are copied from Apache Ignite.
+:: See https://github.com/apache/ignite for more details.
+::
+
+Setlocal EnableDelayedExpansion
+
+if "%OS%" == "Windows_NT"  setlocal
+
+:: Check JAVA_HOME.
+if defined JAVA_HOME goto checkJdk
+    echo %0, ERROR:
+    echo JAVA_HOME environment variable is not found.
+    echo Please point JAVA_HOME variable to location of JDK 1.8 or later.
+    echo You can also download latest JDK at http://java.com/download.
+goto :eof
+
+:checkJdk
+:: Check that JDK is where it should be.
+if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion
+    echo %0, ERROR:
+    echo JAVA is not found in JAVA_HOME=%JAVA_HOME%.
+    echo Please point JAVA_HOME variable to installation of JDK 1.8 or later.
+    echo You can also download latest JDK at http://java.com/download.
+goto :eof
+
+:checkJdkVersion
+set cmd="%JAVA_HOME%\bin\java.exe"
+for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do (
+    set var=%%f
+    goto :escape
+)
+:escape
+
+for /f "tokens=1-3  delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c
+set JAVA_VER_STR=%JAVA_VER_STR:"=%
+
+for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set 
MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b
+if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER%
+
+if %MAJOR_JAVA_VER% LSS 8 (
+    echo %0, ERROR:
+    echo The version of JAVA installed in %JAVA_HOME% is incorrect.
+    echo Please point JAVA_HOME variable to installation of JDK 1.8 or later.
+    echo You can also download latest JDK at http://java.com/download.
+       goto :eof
+)
+
+:: Absolute directory path of this script.
+pushd "%~dp0"
+set SCRIPT_HOME=%CD%
+popd
+
+:: Filename of the script.
+set SCRIPT_NAME=%~nx0
+
+:: NLPCraft installation home.
+pushd "%SCRIPT_HOME%"\..
+set INSTALL_HOME=%CD%
+popd
+
+:: Directory containing JARs.
+set BUILD_HOME=%INSTALL_HOME%\build
+
+:: Build classpath.
+for %%f in ("%BUILD_HOME%"\*.jar) do ( set CP=%%f;!CP! )
+
+set MAIN_CLASS=org.apache.nlpcraft.model.tools.cmdline.NCCommandLine
+set JVM_OPTS= ^
+    -ea ^
+    -Xms1g ^
+    -Xmx1g ^
+    -server ^
+    -XX:+UseG1GC ^
+    -XX:MaxMetaspaceSize=256m ^
+    -DNLPCRAFT_CLI_SCRIPT="%SCRIPT_NAME%" ^
+    -DNLPCRAFT_CLI_INSTALL_HOME="%INSTALL_HOME%"
+
+"%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "%CP%" %MAIN_CLASS% %*
diff --git a/bin/nlpcraft.sh b/bin/nlpcraft.sh
index b9e7d69..8373fe4 100644
--- a/bin/nlpcraft.sh
+++ b/bin/nlpcraft.sh
@@ -16,9 +16,10 @@
 # limitations under the License.
 #
 
-# Absolute path of this script.
+# Absolute directory path of this script.
 SCRIPT_HOME="$(dirname "$(readlink -f "$0")")"
 
+# Filename of the script.
 SCRIPT_NAME="$(basename "$0")"
 
 # NLPCraft installation home.

Reply via email to