aspose file tools*
The moose likes Groovy and the fly likes Interesting Groovy Problem  - Request for Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Interesting Groovy Problem  - Request for Help" Watch "Interesting Groovy Problem  - Request for Help" New topic
Author

Interesting Groovy Problem - Request for Help

Dave Schick
Greenhorn

Joined: Sep 01, 2006
Posts: 13
I've got a situation where I'm trying to use the following java statement to find a class compiled by groovy and it's throwing a ClassNotFoundException:

Class findClass = Class.forName("tester.Rule_rule1);

Rule_rule1 is the class name of the groovy class that's been compiled to byte code and is sitting in the package named "tester".

If I use the same statement for a java source file that's been compiled and is under the "tester" package, it finds the class just find.

Any ideas? Thank you!


Dave Schick (SCJP 5.0, SCWCD)
Matthew Taylor
Rancher

Joined: Jun 13, 2004
Posts: 110
That should work. All Groovy classes can be treated exactly as Java classes.

Can you look in your output directory to ensure there is a Rule_rule1.class file in the tester package? If there is a class file there with the correct name, it doesn't matter whether Java or Groovy created it.

Of course, the Groovy jar must be present in the project classpath to load a Groovy class, but if you've got Groovy already in your project, it should be there.

Also, can you give more context to this issue and maybe a stacktrace? Tell us why you are loading a Groovy class from Java and maybe we can help you find a better way.


Grails Consultant
http://dangertree.net
 
wood burning stoves
 
subject: Interesting Groovy Problem - Request for Help