Linux
#!/bin/sh
BASEDIR=$(dirname "$0")
echo "$BASEDIR"
Windows
%~dp0: the full path of the directory in which the batch script resides.
You can specify the location of myLib.jar regardless of where the batch file is executed.
set JAVA_CMD="%JAVA_HOME%\bin\java" -XX:MaxPermSize=512m -Xms1g -Xmx4g -Duser.language=en
%JAVA_CMD% -jar %~dp0\myLib.jar %*