# Instantiate class from string

**URL:** <https://discourse.processing.org/t/instantiate-class-from-string/32006>\
**Category:** Coding Questions\
**Created:** [August 30, 2021, 7:12am UTC](https://discourse.processing.org/t/instantiate-class-from-string/32006 "2021-08-30T07:12:15Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 31, 2021, 3:02pm UTC](https://discourse.processing.org/t/instantiate-class-from-string/32006/3 "2021-08-31T15:02:25Z")

</div>

Re: reflection on this forum:

- [Java Reflections cheatsheet for processing](https://discourse.processing.org/t/java-reflections-cheatsheet-for-processing/16778)
- [[SOLVED] Instantiating a particular class constructor using reflection](https://discourse.processing.org/t/solved-instantiating-a-particular-class-constructor-using-reflection/7968)
- [https://forum.processing.org/two/discussion/27164/string-to-class-classnotfoundexception#Item\_3](https://forum.processing.org/two/discussion/27164/string-to-class-classnotfoundexception#Item_3)

@GoToLoop has spent quite a bit of time on reflection in Processing.

* * *

The Processing API uses a related technique, a string as a method name (rather than a class name) in, for example, [selectFolder](https://processing.org/reference/selectFolder_.html) – internally it calls selectMethod, which uses `.getMethod()` to turn the text `String callbackMethod` argument given to selectFolder into the corresponding Processing function (`Method selectMethod`) for the callback.

> <https://github.com/processing/processing/blob/36b3990ce3df4b5a8bc40e6e428532bc5aeca3d8/core/src/processing/core/PApplet.java#L6711-L6720>

---

_[View the full topic](https://discourse.processing.org/t/instantiate-class-from-string/32006)._
