<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我的漫漫程序之旅

    專注于JavaWeb開發
    隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
    數據加載中……

    Groovy之旅系列九(Groovy常見命令)

    如果需要用Shell來執行Groovy腳本的話,可以用以下三個命令。

    1.groovysh: 啟動一個groovysh命令行shell,來執行groovy代碼交互。

    2.groovyConsole: 啟動一個可以執行groovy代碼的圖形界面,另外,groovyConsole還可以加載和執行Groovy腳本文件。

    3.groovy : 啟動groovy的腳本解釋程序。單行的groovy腳本可以作為命令行參數被指定。

     一:讓我們先來看看groovysh吧。
    在這個命令中,對于所有的腳本和代碼塊你都需要在shell中完成。相對來說,它還是比較簡便的。

    打一個shell,在命令行中輸入:groovysh

    你會看到如下提示:
    Groovy Shell (1.5.5, JVM: 10.0-b19)
    Type 
    'help' or '\h' for help.
    -----------------------------------------
    groovy:
    000>

    在命令行上輸入"Hello World",如:
    groovy:000> "Hello World"
    ===> Hello World

    這是最簡單的Hello World程序。

    我們繼續在命令行內輸入help或?,會有相應的命令提示:
    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
      show     (\S) Show variables, classes or imports
      inspect  (\n) Inspect a variable or the last result with the GUI object br
    r
      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

    For help on a specific command type:
        help command


    Display命令:
    Display顯示你上次運行的非命令代碼。
    groovy:000> display
    -->Hello World

    Binding命令:
    Binding顯示在一個groovysh會話里可以利用的變量 .在一些簡單的例子中我們不常用變量,但是,為了演示,
    在下面的例子中,我們改進一下:"Hello World"用變量
    greeting去控制消息輸出部分:
    groovy> greeting = "Hello"
    groovy
    > "${greeting}, World!"
    groovy
    > go
    ===> Hello, World!
    groovy
    > binding
    Available variables in the current binding
    greeting 
    = Hello

    Inscept命令:
    Inscept命令會打開一個Groovy Object Browser并定位 在最近的有值表達式上.
    這個一個用Swing做的圖形用戶界面,顯示了有效的方法列表和已經注冊的元方法。


    你還可以控制輸出的格式:
    groovy> 'test'.center 20'-'
    groovy
    > go
    ===> --------test--------

    二 :GroovyConsole命令

    提供了一個執行Groovy 腳本的圖形化界面。

    三:Groovy命令
    假設有一個groovy文件
    current = 1
    next    
    = 1
    10.times {   
       print current 
    + ' '
       newCurrent 
    = next
       next 
    = next + current
       current 
    = newCurrent
    }

    println 
    ''
    loop  
    10 times
    我們保存為 test.groovy
    執行
    groovy test.groovy即可執行這個文件。

    當然也可以先編譯:
    groovyc test.groovy
    這時會生成test.class
    再執行:
    groovy test
    即可正確執行.


    posted on 2008-05-26 14:53 々上善若水々 閱讀(1820) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲一区欧洲一区| 免费亚洲视频在线观看| 国产免费AV片在线播放唯爱网| 亚洲一区二区三区免费在线观看| 在线免费观看国产视频| 久久性生大片免费观看性| 亚洲综合激情九月婷婷| 国产乱子伦精品免费女| 暖暖日本免费中文字幕| 亚洲精品无码不卡在线播放| 亚洲伊人成无码综合网 | 中文字幕免费在线视频| 亚洲成av人片在线看片| 亚洲第一黄色网址| 曰批视频免费40分钟试看天天| 国产偷国产偷亚洲清高APP| 日韩va亚洲va欧洲va国产| 大学生高清一级毛片免费| 手机看片国产免费永久| 亚洲JLZZJLZZ少妇| 亚洲视频在线免费播放| 亚洲精品NV久久久久久久久久| 精品香蕉在线观看免费| 中文在线免费不卡视频| 亚洲国产精品无码第一区二区三区 | 国产麻豆视频免费观看| a级在线免费观看| 美景之屋4在线未删减免费 | 亚洲色中文字幕无码AV| 精品久久免费视频| 国产大片免费网站不卡美女| 国产高潮久久免费观看| 亚洲精品无码久久久久秋霞| 亚洲国产精品久久66| 亚洲综合区小说区激情区| 妞干网在线免费观看| 99久久99久久免费精品小说| 国产精品1024在线永久免费| 亚洲大码熟女在线观看| 亚洲AV色吊丝无码| 亚洲天堂福利视频|