Added safeguard to ensure scriptName is defined when called from Java / Jython