# Why does .getConstructor fail with a NoSuchMethodException despite zero-arg constructors existing for the class?

**URL:** https://discourse.processing.org/t/why-does-getconstructor-fail-with-a-nosuchmethodexception-despite-zero-arg-constructors-existing-for-the-class/45748
**Category:** Coding Questions
**Tags:** homework
**Created:** [February 12, 2025, 3:14pm UTC](https://discourse.processing.org/t/why-does-getconstructor-fail-with-a-nosuchmethodexception-despite-zero-arg-constructors-existing-for-the-class/45748 "2025-02-12T15:14:08Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [February 12, 2025, 4:33pm UTC](https://discourse.processing.org/t/why-does-getconstructor-fail-with-a-nosuchmethodexception-despite-zero-arg-constructors-existing-for-the-class/45748/3 "2025-02-12T16:33:45Z")

</div>

> [@java.lang.NoSuchMethodException from a Class.forName instantiation](https://discourse.processing.org/t/java-lang-nosuchmethodexception-from-a-class-forname-instantiation/37961/6):
>
> The 3 classes (Dumb, Dumber, Dummy) in my example are both non-static & non-public. So it’s very possible to find such classes as my example already demonstrates. I’ve split up getDumb() into 2 functions in a separate tab: getSketchInnerClassConstructor() → returns a Class’ Constructor. instantiateSketchInnerClass() → returns an instance from a Constructor. Also made 2 functions to find nested classes: findAllSketchInnerClasses() → returns an array of all inner classes. findSketchNested…

> [@\[SOLVED\] Instantiating a particular class constructor using reflection](https://discourse.processing.org/t/solved-instantiating-a-particular-class-constructor-using-reflection/7968):
>
> Hello again, oh great Java gurus! star_struck I find myself having to instantiate a class from a string using one of its particular constructors. The [api for getDeclaredConstructors()](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredConstructor-java.lang.Class...-) indicates this is possible, but the examples I’ve found online of its implementation aren’t clicking for me. Here’s a stripped-down example of what I’m hoping to achieve. import java.lang.reflect.\*; // This PApplet processing session // final String THISPROC = this.getClass().getCanonicalName(); final PApplet…

---

_[View the full topic](https://discourse.processing.org/t/why-does-getconstructor-fail-with-a-nosuchmethodexception-despite-zero-arg-constructors-existing-for-the-class/45748)._
