Beside the two syntax errors - missing ';' after println.. and trailing '*' after closing project tag - you should upgrade your ant installation to a version >= 1.7.x in conjunction with jdk >= 6 to be able to use the builtin javascript engine.
When using jdk >=6 the use of println is no problem, see :
import javax.script.*;
public class ExecuteJS {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval("print('Line1')");
engine.eval("println('Line2')");
engine.eval("print('Line3')");
engine.eval("println('Line4')");
}
}
output :
Line1Line2
Line3Line4
and
<project>
<script language="javascript">
println("hello, world");
</script>
</project>
But further testing with Ant 1.9.0 / Win7 (my linux box is down right now) / jdk1.7.0_21 revealed some oddities :
<project>
<script language="javascript">
println("hello, world");
</script>
</project>
works
<project default="foo">
<target name="foo">
<script language="javascript">
println("hello, world");
</script>
</target>
</project>
works also
<project name="whatever" default="foo">
<target name="foo">
<script language="javascript">
println("hello, world");
</script>
</target>
</project>
works also, whereas
<project name="java" default="foo">
<target name="foo">
<script language="javascript">
println("hello, world");
</script>
</target>
</project>
results in
BUILD FAILED
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot read property "PrintWriter" from undefined (print#8) in print at line number 8
Strange !?
Seems like a bug, so finally upgrade ant >= 1.7.x and jdk >= 1.6 and
don't use 'java' in name attribute of project :-)