第 1 章 起步

第 1 章 起步

1.2 管理多個版本的 Groovy

參考筆記 SDKMAN Practice

$ sdk install groovy 2.4.1

1.3 使用 groovysh

打開交互式終端

$ groovysh
Groovy Shell (2.1.1, JVM: 1.7.0_141)
Type 'help' or '\h' for help.
groovy:000> help

For information about Groovy, visit:
    http://groovy.codehaus.org 

Available commands:
  help      (\h ) Display this help message
  ?         (\? ) Alias to: help
  exit      (\x ) Exit the shell
  quit      (\q ) Alias to: exit
  import    (\i ) Import a class into the namespace
  display   (\d ) Display the current buffer
  clear     (\c ) Clear the buffer and reset the prompt counter.
  show      (\S ) Show variables, classes or imports
  inspect   (\n ) Inspect a variable or the last result with the GUI object browser
  purge     (\p ) Purge variables, classes, imports or preferences
  edit      (\e ) Edit the current buffer
  load      (\l ) Load a file or URL into the buffer
  .         (\. ) Alias to: load
  save      (\s ) Save the current buffer to a file
  record    (\r ) Record the current session to a file
  history   (\H ) Display, manage and recall edit-line history
  alias     (\a ) Create an alias
  set       (\= ) Set (or list) preferences
  register  (\rc) Registers a new command with the shell

For help on a specific command type:
    help command 

1.5 在命令行中運行 Groovy

$ cat Hello.groovy 
println "Hello Groovy!"
$ groovy Hello.groovy 
Hello Groovy!

在命令行中直接運行一些語句

$ groovy -e "println 'hello'"
hello
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容