Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interesting Groovy Problem - Request for Help

 
Dave Schick
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Matthew Taylor
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic