<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 々上善若水々 閱讀(1825) 評論(0)  編輯  收藏


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


    網站導航:
     
    主站蜘蛛池模板: 69式互添免费视频| 亚洲码国产精品高潮在线| 尤物永久免费AV无码网站| 老司机亚洲精品影视www| 亚洲大片免费观看| sss日本免费完整版在线观看| 国产一级高青免费| 免费无码又爽又高潮视频 | 亚洲日本va午夜中文字幕一区| 亚洲高清免费视频| 亚洲另类激情综合偷自拍图| 免费网站观看WWW在线观看| 黄网址在线永久免费观看| 中文日韩亚洲欧美制服| 香蕉免费一区二区三区| 亚洲好看的理论片电影| 国产91色综合久久免费分享| 在线观看亚洲AV每日更新无码| 在线观看免费精品国产| 一区二区三区免费精品视频 | 久久狠狠躁免费观看| 久久精品国产亚洲AV麻豆~| 亚洲一区二区三区免费视频| 亚洲熟妇无码AV不卡在线播放 | 亚洲日韩av无码| 亚洲免费视频网址| 久久综合亚洲色hezyo| 亚洲最大AV网站在线观看| 99re在线这里只有精品免费| 亚洲人成在线中文字幕| 免费一级一片一毛片| 久久精品成人免费看| 亚洲日日做天天做日日谢| 午夜亚洲国产成人不卡在线| 久久精品电影免费动漫| 亚洲午夜理论片在线观看| 丝袜熟女国偷自产中文字幕亚洲| 97精品免费视频| 曰批全过程免费视频免费看| 麻豆亚洲AV永久无码精品久久| 中文字幕永久免费|