Synology Scheduler .sh java command not found

When the Synology task scheduler executes the script sms.sh the PATH setting is taken from script /etc/crontab. Which does not contain the Java path.

The default login shell environment is defined int /etc/profile. At the end there is a section to add the Java path.

PATH=$PATH:/var/packages/Java8/target/j2sdk-image/bin # Synology Java runtime enviroment
PATH=$PATH:/var/packages/Java8/target/j2sdk-image/jre/bin # Synology Java runtime enviroment
JAVA_HOME=/var/packages/Java8/target/j2sdk-image/jre # Synology Java runtime enviroment
CLASSPATH=.:/var/packages/Java8/target/j2sdk-image/jre/lib # Synology Java runtime enviroment
LANG=en_US.utf8 # Synology Java runtime enviroment
export CLASSPATH PATH JAVA_HOME LANG # Synology Java runtime enviroment

As already stated in already given comments sourcing a profile script which is meant for an interactive shell isn't suggested. You might mimic the behavior of the /etc/profile script in your sms.sh script to set CLASSPATH PATH JAVA_HOME LANG.

The raised points about hardcoding the path in your script and the resulting reduced portability might have a lover precedence in this specific case.