Core examples addition

40 views
Skip to first unread message

Stuart Maclean

unread,
Jul 16, 2015, 8:31:30 PM7/16/15
to metsci-...@googlegroups.com
As a newbie, I was very interested to run all the 'core-examples'.  Though the module builds fine (I'm on Linux, java7), i could not find much in the way of help regarding running the examples, and thus found no easy way to even discover what the examples could do.

To alleviate these problems, I first hacked the pom to make the code more easily runnable, using aspects of Maven's jar and dependency plugins.

I then added a Menu class (edu.uw.apl.glimpse.examples.Menu) which enumerates all the example classes (I think there are 43 currently), prints a simple menu and runs whichever example is selected.  It's a hack I admit, but useful to me nonetheless and perhaps to others.

I have not yet published this as a pull request, i just wanted to see if anyone thought it useful.  I am a newbie to all things github too.

The url is

github.com:UW-APL-EIS/glimpse.git

Feedback welcomed.

Stuart

Geoffrey Ulman

unread,
Jul 17, 2015, 2:03:24 PM7/17/15
to metsci-...@googlegroups.com, sdma...@gmail.com

Cool! I checked out your fork and was able to run your example launcher.

I agree that providing a more discoverable way to run the examples directly from Maven would be useful.

I would note that you can run the Examples from Maven directly using mvn exec:java. From the core-examples directory, you would type:

mvn exec:java -Dexec.mainClass="com.metsci.glimpse.examples.basic.ScatterplotExample"

I do like the capability to auto-discover and list the available examples.

Your Menu class works fine for me when I run it from the compiled jar, but if I run it using:

mvn exec:java -Dexec.mainClass="edu.uw.apl.glimpse.examples.Menu"

I get:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1954)
at edu.uw.apl.glimpse.examples.Menu.main(Menu.java:86)

It looks like the URL format is different than you're expecting when the resources are not packaged inside a jar (I see from the comment in your code that you were already worried about those types of issues).

As an aside, we do also have a Java WebStart application which enumerates all the examples in a dialog and allows the user to run them: http://glimpse.metsci.com/jnlp/launch.jnlp. But I'd see that capability as complimentary and serving a slightly different purpose than a capability to easily run the examples from Maven. For one thing, the WebStart only allows you to run examples for the current release version, so you can't really experiment with modifying the examples.

Stuart Maclean

unread,
Jul 17, 2015, 2:04:05 PM7/17/15
to metsci-...@googlegroups.com
Realized I hadn't given any hints on how to invoke my 'examples menu' program.  From the given github url download:

$ mvn install

$ cd core-examples

$ java -jar target/glimpse-core-examples-CURRENT-SNAPSHOT.jar

or

$ java -jar target/glimpse-core-examples-CURRENT-SNAPSHOT.jar N

for some N in 1 .. 43

I'll look next at the extra-examples.

Stuart

Stuart Maclean

unread,
Jul 17, 2015, 7:41:07 PM7/17/15
to metsci-...@googlegroups.com
To follow up Geoff's concern about the Menu not working via 'mvn exec:java', I have improved the classpath identification logic somewhat.  Still only tested on Linux though.


Stuart


On Thursday, July 16, 2015 at 5:31:30 PM UTC-7, Stuart Maclean wrote:
Reply all
Reply to author
Forward
0 new messages