Another shot at Groovy: Groovy + Scriptom
Article Outdated, please see tutorial here
Sciptom in Netbeans
If at first you don't succeed...
Since my home computer is 64-bit Windows, I'd like to try scriptom again with a fairly vanilla setup. I'm still trying to evaluate its usefulness in my application, but I can't get it to work!
The above link provides quick instructions to obtain a "Development Build" of Netbeans for working with Groovy. I downloaded it and extracted it to my desktop. It does not seem to conflict with my current Netbeans installation. So I can delete the folder when I'm done if I decide not to use it.
Simply double click "netbeans.exe" in the "bin" folder, and Netbeans should launch. I already had Netbeans Beta 2 installed, so if there's extra steps I appologize!
In Tools >> Plugins, simply type "groovy" in the search field (make sure you're on the "Available Plugins" tab).
As long as you can connect to deadlock.netbeans.org you should be in business. It took a while, but I eventually connected and got my list of plugins.
Once installed it will ask you to restart the Netbeans IDE. Once restarted, you can create a new Groovy project!
I used the same sample as before:
Ok... So I create the "lib" folder inside the Netbeans Dev folder:
Now I get a new error:
In order to get the Groovy jar (1.0 is the stable release that Netbeans claims to work with), I go to: http://groovy.codehaus.org/Download and download the Windows installer for version 1.0. After taking defaults, it places a Groovy-1.0.jar in C:\Program Files\Groovy. I'm copying that to the Desktop\netbeans\lib folder.
And now I get:
I extracted the zip, and copied "commons-cli-1.1.jar", to Desktop/netbeans/lib, just like Groovy-1.0.jar.
More errors! Yippee!
These all seem to be packages that exist in C:\Program Files\Groovy. I'll see what I can do to get that added to the classpath of the project. Not that I know how to do that in Groovy! :\
Added C:\program files\groovy\lib\ as a directory, but no luck.
So I'm going to Options >> Miscelaneous >> Ant Tab >> Classpath >> Add JAR/ZIP, and selecting all of them. Navigate to C:\program files\groovy\lib\ hit CTRL+A and then OK.
You should see something like this:
No luck. I'll copy them to the netbeans/lib folder I guess.... Its only 8MB, so its not too much of a hassle.
New error:
You've got to be kidding me...
Upon further investigation... the ActiveXObject isn't even in this version of Scriptom!
Look at what I get with the Package explorer in Netbeans:
Let me try to find a Groovy 1.0 compatible version that has the Classes we need... Jeez Louise!
Ok, I found a Scriptom 1.2 with the following disclaimer:
Notice "ActiveXProxy", instead of "ActiveXObject". Looks like the new version is the only option.
Now I'll download and install the "Upcomming Release" of Groovy from http://groovy.codehaus.org/Download. Install as normal, and copy the libs over again.
Done.
I try running it again and get:
Now I'm going to make a last effort to download the latest Jacob from http://sourceforge.net/projects/jacob-project/. I will now replace jacob.jar in /netbeans/lib, and replace jacob.dll in the root of my project folder (My Documents >> Netbeans Projects >> PROJECTNAME).
Success!
I'll publish a quick start howto shortly.
-Tres
Sciptom in Netbeans
If at first you don't succeed...
Since my home computer is 64-bit Windows, I'd like to try scriptom again with a fairly vanilla setup. I'm still trying to evaluate its usefulness in my application, but I can't get it to work!
http://groovy.codehaus.org/NetBeans+Plugin
The above link provides quick instructions to obtain a "Development Build" of Netbeans for working with Groovy. I downloaded it and extracted it to my desktop. It does not seem to conflict with my current Netbeans installation. So I can delete the folder when I'm done if I decide not to use it.
Simply double click "netbeans.exe" in the "bin" folder, and Netbeans should launch. I already had Netbeans Beta 2 installed, so if there's extra steps I appologize!
In Tools >> Plugins, simply type "groovy" in the search field (make sure you're on the "Available Plugins" tab).
As long as you can connect to deadlock.netbeans.org you should be in business. It took a while, but I eventually connected and got my list of plugins.
Once installed it will ask you to restart the Netbeans IDE. Once restarted, you can create a new Groovy project!
I used the same sample as before:
// Groovy source fileAnd here's the Output from Netbeans:
import org.codehaus.groovy.scriptom.*;
def name='World'
println "Hello $name!"
Scriptom.inApartment
{
def ie = new ActiveXObject('InternetExplorer.Application')
ie.Visible = true
ie.AddressBar = true
ie.Navigate "http://glaforge.free.fr/weblog"
}
C:\... ...nbproject\build-impl.xml:87: C:\... ...netbeans\lib not found.Which points to:
BUILD FAILED (total time: 0 seconds)
I can't get this to work. This is ridiculous.
Ok... So I create the "lib" folder inside the Netbeans Dev folder:
Now I get a new error:
C:\... ...nbproject\build-impl.xml:87: taskdef class org.codehaus.groovy.ant.Groovyc cannot be foundI guess I can try putting the Groovy jar inside that lib folder, but I would have thought the plugin would do this for me...
BUILD FAILED (total time: 0 seconds)
In order to get the Groovy jar (1.0 is the stable release that Netbeans claims to work with), I go to: http://groovy.codehaus.org/Download and download the Windows installer for version 1.0. After taking defaults, it places a Groovy-1.0.jar in C:\Program Files\Groovy. I'm copying that to the Desktop\netbeans\lib folder.
And now I get:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParserA google shows that this is part of the Apache Commons CLI. It has a Javadoc, so I'm hoping its a jar... Downloading it from here: http://commons.apache.org/downloads/download_cli.cgi
at groovy.lang.GroovyShell.main(GroovyShell.java:81)
I extracted the zip, and copied "commons-cli-1.1.jar", to Desktop/netbeans/lib, just like Groovy-1.0.jar.
More errors! Yippee!
Caught: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
Java Result: 1
These all seem to be packages that exist in C:\Program Files\Groovy. I'll see what I can do to get that added to the classpath of the project. Not that I know how to do that in Groovy! :\
Added C:\program files\groovy\lib\ as a directory, but no luck.
So I'm going to Options >> Miscelaneous >> Ant Tab >> Classpath >> Add JAR/ZIP, and selecting all of them. Navigate to C:\program files\groovy\lib\ hit CTRL+A and then OK.
You should see something like this:
No luck. I'll copy them to the netbeans/lib folder I guess.... Its only 8MB, so its not too much of a hassle.
New error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, src\grooves\Main.groovy: 12: unable to resolve class ActiveXObject
@ line 12, column 14.
def ie = new ActiveXObject('InternetExplorer.Application')
^
You've got to be kidding me...
Upon further investigation... the ActiveXObject isn't even in this version of Scriptom!
Look at what I get with the Package explorer in Netbeans:
Let me try to find a Groovy 1.0 compatible version that has the Classes we need... Jeez Louise!
Ok, I found a Scriptom 1.2 with the following disclaimer:
This is the page of the old version of Scriptom. As the new version, Scriptom 2.0, brings with it a couple breaking changes, you may still want to use this version. However, we highly encourage you to switch to the newer version which solves a certain number of bugs and provide a much better integration to COM / ActiveX components.And the source code examples are different!
import org.codehaus.groovy.scriptom.ActiveXProxy
// instantiate Internet Explorer
def explorer = new ActiveXProxy("InternetExplorer.Application")
// set its properties
explorer.Visible = true
explorer.AddressBar = true
// navigate to a site by calling the Navigate() method
explorer.Navigate("http://glaforge.free.fr/weblog")
Now I'll download and install the "Upcomming Release" of Groovy from http://groovy.codehaus.org/Download. Install as normal, and copy the libs over again.
Done.
I try running it again and get:
Caught: java.lang.UnsatisfiedLinkError: no jacob in java.library.pathSo I'll put the dll in the root of my project folder (I won't copy it to System32 due to security issues, and frequent versioning), and I get the following error:
at Main.run(Main.groovy:10)
at Main.main(Main.groovy)
Java Result: 1
Caught: java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.Variant at Main.run(Main.groovy:10) at Main.main(Main.groovy)So we are back to square one. Note I am using the Jacob.jar and Jacob.dll provided with Scriptom 2.0.
Now I'm going to make a last effort to download the latest Jacob from http://sourceforge.net/projects/jacob-project/. I will now replace jacob.jar in /netbeans/lib, and replace jacob.dll in the root of my project folder (My Documents >> Netbeans Projects >> PROJECTNAME).
Success!
I'll publish a quick start howto shortly.
-Tres
Comments