I had seen a video where, main()
can be run with in an enum
.
I am trying to do the same but it's not working.
Here is my code
public enum EnumMain {
ABC, XYZ;
public static void main(String[] args) {
System.out.print("MIAN");
}
}
Output
(The code compiles fine)
Error: Could not find or load main class EnumMain
I think this has something to do with the Java version, may be in Java 8, they are not allowing to run main()
method from enum
anymore.
PS I am compiling and running the file from windows command prompt.
Note If I change the enum
to class
then it runs fine (I don't have any classpath issues)