[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    Re: [groovy-user] running Groovy from java command line
From:       Jochen Theodorou <blackdrag () gmx ! org>
Date:       2007-04-30 9:07:51
Message-ID: 4635B1E7.3000300 () gmx ! org
[Download RAW message or body]

bslade schrieb:
> I'm having similar problems (on Mac OS X) trying to use a java music jar
> file:
> 
> $ env | grep CLASSPATH
> CLASSPATH=/Users/bslade/Library/Groovy
 >
 > // Note, I softlinked the Groovy .jar files into this dir.  It maybe
 > uneccessary, but it shouldn't hurt anything:
 > $ ls -l /Users/bslade/Library/Groovy
 > lrwxr-xr-x   1 bslade  bslade     39 Apr 30 00:18 commons-cli-1.0.jar
 > -> /Library/Groovy/lib/commons-cli-1.0.jar
 > lrwxr-xr-x   1 bslade  bslade     45 Apr 30 00:30 groovy-all-1.0.jar
 > -> /Library/Groovy/embeddable/groovy-all-1.0.jar
 > -rw-r--r--   1 bslade  bslade  97335 Apr 29 23:52 jfugue.jar

hmm... I don't remember clearly but unless the it is now possible to put 
directories containing jars in the classpath, this is no valid 
classpath... At last in java5 the jars would not be used. I don't know 
your version on Mac, but this seems to be no groovy but a java problem.

> $ cat jfugue_demo.groovy
> import org.jfugue.*;
> Player player = new Player();
> Pattern pattern = new Pattern("C D E F G A B");
> player.play(pattern);
> 
> // This *should* use the CLASSPATH env variable, but...
> $ groovyc jfugue_demo.groovy         
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed, jfugue_demo.groovy: 6: unable to resolve class Player 
> ...snip...

won't work for groovyc, groovyc needs the classic classpath way... so 
you ahve to list all jars.

> // But if I explicitly specify the jar file, it *does* compile:
> $ groovyc -classpath $CLASSPATH/jfugue.jar jfugue_demo.groovy
> 
> // But then when I try and run it, it give errors similar to fschmidt's:
> $ java jfugue_demo
> Exception in thread "main" java.lang.NoClassDefFoundError: jfugue_demo
> 
> // Same result when I explicitly state class/jar locations:
> $ java -cp
> "$GROOVY_HOME/embeddable/groovy-all-1.0.jar;$GROOVY_HOME/lib/commons-cli-1.0.jar;$CLASSPATH/jfugue.jar"
> jfugue_demo
> Exception in thread "main" java.lang.NoClassDefFoundError: jfugue_demo

ok, but that's another exception. You need to add "." as well, how else 
should java find the class?

> Interestingly, if I change the filename of the class that is supposed to be
> run, it gives the same error message (with the new classname):
> $ java xxx
> Exception in thread "main" java.lang.NoClassDefFoundError: xxx

well if there is no xxx.class file somewhere it is no wonder.

> So it looks like it's not finding the class file I just compiled (which was
> created).   I hope this doesn't turn out to be something incredibly obvious
> ;)

incredibly obvious ^^

bye blackdrag

-- 
Jochen "blackdrag" Theodorou
Groovy Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic