Monday, December 3, 2007

A Groovy Way to Start Programming - Getting Started With Scriptom in NetBeans 6

Scriptom + Netbeans Quickstart Guide

Needed: (Download all of these before beginning)

Instructions:

  1. Download all files above.

  2. Extract Netbeans-Java to Deskop in a folder called "netbeans"

  3. Inside this folder (where LISCENSE.TXT is), create a new folder "lib".

  4. Extract Groovy 1.X/embeddable/groovy-all-1.x.jar to Desktop\netbeans\lib. (the "lib" folder you just created)

  5. Open Scriptom-2.x.zip and extract Scriptom-2.X.jar to Desktop\netbeans\lib.

  6. Open jacob_1.x.zip and extract jacob.jar to Desktop\netbeans\lib. (When prompted to overwrite, click YES)


















  7. Extract jacob.dll to Desktop. (Most people can use the version in the x86 folder)

  8. Navigate to Desktop\netbeans\bin, and right click netbeans.exe >> Send To >> Desktop.

  9. Close out all open windows.

  10. Open Netbeans by clicking the shortcut we just created.
    (It will take about 3 minutes. If you've tried installing the Groovy module befor and recieve errors, click "disable and continue", then remove Groovy from Tools >> Plugins, restart Netbeans, then Continue)
  11. In Netbeans, go to Tools >> Plugins >> and wait for the plugin listing to show up. If there are only 20 or so plugins, try to refresh it.
  12. In the search bar, type "groovy", and check it in the list, then click the install button.
    (This will install Groovy scripting support in Netbeans)

    *Note: If you have special proxy settings, Netbeans can be configured to use them, but it should work fine with your computer's default settings.

  13. Once its finished downloading and installing, it will prompt you to restart your IDE Click Yes (Restart Netbeans).

  14. Make a new Groovy project by navigating to File >> New Project >> Groovy Application. Give it a good name, like "GroovyTest". If you get some message dialogs, take defaults.

  15. Before we continue, the jacob.dll that was placed on the Desktop needs to be added to your PATH. Some people prefer to copy this to C:\Windows\System32. There are other locations that may work too, but I highly recommend placing jacob.dll it in the root of your project path, at My Documents\NetbeansProjects\GroovyTest.

    *Note: The logic behind this is the programmer should keep track of required dlls on a per-project basis, because, in my opinion, Groovy, and Scriptom do a horrible job of maintaining file versions (If you don't believe me, see the last two day's articles)


















  16. OK, now we're ready to code!

  17. Lets open your new file by double-clicking on it in your Navigator. It should be called "Main", unless you gave it a different name.

  18. You should see Groovy already made some sample code. We can leave it there. Add this code to the bottom of it (taken from Scriptom-2.0.zip/examples/ie/IE.groovy):

    [code]
    import org.codehaus.groovy.scriptom.*;
    Scriptom.inApartment
    {
    def ie = new ActiveXObject('InternetExplorer.Application')
    ie.Visible = true
    ie.AddressBar = true
    ie.Navigate "http://www.google.com/search?&q=site%3Ablogspot.com+fatbuttlarry"
    }
    [/code]

  19. Save the file by clicking the Disk icon in the top left corner of the toolbar.


  20. Run the program by pressing the green "Play" button in the center of the toolbar.


  21. Clean up all downloaded files, leaving the Netbeans Shortcut and the Netbeans folder.

No comments: