<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)  編輯  收藏


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


    網站導航:
     
    主站蜘蛛池模板: 一级毛片免费观看不收费| 朝桐光亚洲专区在线中文字幕| 精品久久久久久国产免费了| 免费一级e一片在线播放| 噜噜综合亚洲AV中文无码| 国产一区二区三区在线观看免费| 亚洲精品国产第一综合99久久| 妞干网免费观看视频| 亚洲AV综合永久无码精品天堂| 免费a级毛片大学生免费观看| 国产亚洲漂亮白嫩美女在线| mm1313亚洲国产精品美女| 一级A毛片免费观看久久精品| 亚洲精品美女久久777777| 九九精品成人免费国产片| 久久狠狠高潮亚洲精品| 四虎在线成人免费网站| 亚洲中文字幕精品久久| 国产成人精品免费视频软件| 一级黄色免费大片| 亚洲欧洲国产精品你懂的| 四虎在线成人免费网站| 国产区图片区小说区亚洲区| 久久影院亚洲一区| 亚洲香蕉免费有线视频| 亚洲av日韩av永久在线观看| 亚洲国产精品无码中文字| 成人片黄网站A毛片免费| 美女被艹免费视频| 亚洲AV无码一区二区乱子伦| 91麻豆最新在线人成免费观看| 亚洲成AV人影片在线观看| 亚洲日本一区二区三区在线| 一个人免费观看视频www| 成人免费观看男女羞羞视频 | 日韩免费无砖专区2020狼| 成人自慰女黄网站免费大全| 亚洲一卡2卡4卡5卡6卡在线99| 亚洲第一区精品日韩在线播放| 777成影片免费观看| 精品在线观看免费|