File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using reflection for button listeners, throwing ClassNotFound exception

 
Ben Alex Barreto
Greenhorn
Posts: 15
Java Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Me and my team are trying to use reflection to implement the listeners for the buttons in this simple calculator. We are doing this for an engineering class. We added a break point at line 35 "Class aListenerClass = Class.forName(splitString[0]);" because it keeps throwing a ClassNotFound exception, and it's being thrown after we split the string to identify the right listener. The "Controller" you see there, well, we are implementing the Application Controller pattern for the back-end of this calculator...

Why in the world is it throwing ClassNotFound? When we run this on debug mode in eclipse, we can check the value of the split elements, right? Well... it shows "CalculateListener" for the first element of the split string, yet when we expand the element it lists [C,a,l,c,u,l,a,t,e,L,i,s,t,e,n,e,r,_,e,q,u,a,l,s] as it's value--as if the string never got split, but it is being split! Check our code below. I'm also including the R file, so you guys can check all the ids and see how we are implementing reflection here. Please give us some light We would be eternally grateful!

In advance, thank you so much!

Sincerely,

Ben, Diego (0x783czar), Trevor, David, and Steve.



 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure the resulted class name is qualified with its package name. For example: com.yourdomain.CalculateListener
 
Ben Alex Barreto
Greenhorn
Posts: 15
Java Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hussein Baghdadi wrote:Make sure the resulted class name is qualified with its package name. For example: com.yourdomain.CalculateListener


That was exactly right! Thank you o much! We are going past that exception now :-)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic