第 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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容