Linux 平台下
文件名: scala_exec
#!/bin/sh
exec scala "$0" "$@"
!#
// The following should be scala code
// just an example
println("I'm executing in bash, and you input args.." + args[0])
exec scala "$0" "$@"
!#
// The following should be scala code
// just an example
println("I'm executing in bash, and you input args.." + args[0])
和bash脚本一样,#!/bin/sh必需是文件开头的第一行。
然后赋予该脚本可执行权限:
chmod u+x scala_exec
这样你就可以在Linux上像执行shell脚本一样地执行scala脚本了。
./scala_exec "hello"
Windows 平台下
文件名:scala_exec.bat
::#!
@echo off
call scala %0 %*
goto :eof
::!#
@echo off
call scala %0 %*
goto :eof
::!#