Hi,
This is the line: Class ourClass = new Class.forName("com.app.something");

And this is the the error: cannot find symbol class forName

My IDE is Intellij Idea.

This is a particular case, but i want to know what causes this type of error, what should i look for.

Recommended Answers

The keyword "new" is wrong here. You are just calling the static method "forName" in the Class class. It's not a constructor.
Class ourClass = Class.forName("com.app.something");

Jump to Post

All 4 Replies

The keyword "new" is wrong here. You are just calling the static method "forName" in the Class class. It's not a constructor.
Class ourClass = Class.forName("com.app.something");

**new **may be confusing the compiler to look for a constructor.

Yes indeed, thank you, sometime you miss those details.

OK. Please mark this "solved"
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.