• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using reflection for button listeners, throwing ClassNotFound exception

 
Greenhorn
Posts: 15
Mac Objective C Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Objective C Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :-)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic