title: Java enum reflection when enum is inside a class
body: <p>I have multiple instances of classes that have a single enum nested inside them. Here is a simplified version of said class:</p>
  
  <pre><code>public class FirstClass extends BaseClass {
  
    public enum EnumGroup {
        ONE("one"),
        TWO("two");
  
        private String mName;
  
        EnumGroup(String name) {
          this.mName = name;
        }
  
        public String getName() {
          return mName;
        }  
    }
  
    // FirstClass methods
  }
  </code></pre>
  
  <p>My goal is to programmatically iterate over these classes (i.e. FirstClass, SecondClass, etc.) and pull the enum (always called "EnumGroup") out and call the method getName() on each value of the enum.</p>
  
  <p>I've looked at this <a href="https://stackoverflow.com/questions/140537/how-to-use-java-reflection-when-the-enum-type-is-a-class">StackOverflow post</a> on Java reflection and enums, but when I try to fetch my enum by specifying the path (com.package.FirstClass.EnumGroup) I get a ClassNotFoundException. I'm guessing putting the enum inside the class is messing something up.</p>
  
  <pre><code>Class&lt;?&gt; clz = Class.forName("com.package.FirstClass.EnumGroup");
  </code></pre>
  
  <p>I don't necessarily need this set-up, but the end goal is not have the same code in each class that iterates over the enum. </p>