Skip to content

Instantly share code, notes, and snippets.

@neelsmith
Last active February 11, 2024 15:52
Show Gist options
  • Select an option

  • Save neelsmith/8359546 to your computer and use it in GitHub Desktop.

Select an option

Save neelsmith/8359546 to your computer and use it in GitHub Desktop.
groovy: get an instance of a class from its name as a string
def objectInstance = Class.forName("NAME.AS.STRING").newInstance()
@anallely
Copy link
Copy Markdown

๐Ÿ‘

@DanDare2050
Copy link
Copy Markdown

I'm assuming the name is fully qualified

@jairo-henao
Copy link
Copy Markdown

๐Ÿ‘

@thamerbelfkihthamer
Copy link
Copy Markdown

newInstance is depricated since java V9. be careful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment