Java Error Enum Cannot Be Resolved To A Type
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and enum cannot be resolved to a variable policies of this site About Us Learn more about Stack Overflow the enumeration cannot be resolved to a type jsp company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags eclipse enum interface expected Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only java.util.enumeration cannot be resolved takes a minute: Sign up why enum could not be resolved in JAVA? up vote 1 down vote favorite I was using J2EE Eclipse Indigo, and I have three class declare like this: public interface ClassA { public static enum TYPE { TYPE1, TYPE2 }; } public interface ClassB extends ClassA { } public class ClassC implements ClassB { System.out.println(TYPE.TYPE1); }
The Type Java Lang Object Cannot Be Resolved It Is Indirectly Referenced From Required Class Files
There was a compilation error on TYPE in ClassC. It complain that "enum cannot be resolved to a type". And also a warning for enum in ClassA, it complain that: Multiple markers at this line - 'enum' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on - enum cannot be resolved to a type - Syntax error, insert ";" to complete FieldDeclaration May I know what cause the error in this code? java enums share|improve this question edited Jul 9 '14 at 9:46 Nishanthi Grashia 7,33652240 asked Jul 1 '11 at 5:46 huahsin68 2,267105188 add a comment| 4 Answers 4 active oldest votes up vote 8 down vote accepted I had a similar problem: enum can't be resolved to a type Eclipse offered to import Enum instead. I went to Preferences->Java->Installed_JREs->Execution_environment; Selected JavaSE-1.6 in "Execution Environments" pane; and Checked jre6 in Compatible JREs pane. After rebuild enum was recognized properly. share|improve this answer edited Nov 16 '12 at 11:41 Bruno Vieira 3,05811331 answered Nov 16 '12 at 11:15 stuhpa 13116
here for a quick overview of the site Help Center Detailed answers to any questions you might have
How To Use Enum In Java
Meta Discuss the workings and policies of this site About Us java enumeration Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, http://stackoverflow.com/questions/6544054/why-enum-could-not-be-resolved-in-java just like you, helping each other. Join them; it only takes a minute: Sign up The type java.lang.Enum cannot be resolved - Getting error after importing Java project in Eclipse up vote 2 down vote favorite I am getting the following error after importing Java project (Non Maven) in Eclipse: The type java.lang.Enum cannot be resolved. http://stackoverflow.com/questions/30057054/the-type-java-lang-enum-cannot-be-resolved-getting-error-after-importing-java It is indirectly referenced from required .class files I have couple of Java classes in my project and I am getting this compilation error in the first line of this below class (In the package declaration line) package com.test.utils; public enum Currency { PENNY, NICKLE, DIME, QUARTER }; I checked my project's Java Build Path and in the Libraries tab all the jars and JRE System Library are present. Below is the .classpath content
Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums Forum: IDEs, Version Control and other tools Eclipse enum cannot be resolved Gail Schlentz Ranch Hand Posts: https://coderanch.com/t/104553/vc/Eclipse-enum-resolved 634 posted 10 years ago I am in a new job & working http://www.eclipsezone.com/eclipse/forums/t108476.html on a small project. We use Java 1.5, and I have been using Eclipse (v.3.2.0) as my IDE. For 3 weeks now, I've had no problems with the existing code compiling & running. The existing code contains several enum types - no problems. But now, someone checked in some changes to a file, including cannot be adding another enum type and it will not compile - I get the error "My_Component_States cannot be resolved." Here's the code snippet - it is done just like the other enums in our project that compile with no problem, and I'm the only one having an issue with it (and the only one using Eclipse...) public enum My_Component_States { Never_Visible, When_Event_Happens, Always_Visible } Any ideas?? Gail Schlentz cannot be resolved Gail Schlentz Ranch Hand Posts: 634 posted 10 years ago Ok - fixed the problem... I guess... I went into my preferences & found that somehow my "Compiler compliance level" got set back to 1.4 instead of 5.0. But what I don't understand is 1) How it got reset, and 2) If it was throwing errors on one enum, why not all of them?? (Yes, I did do a complete clean & rebuild - multiple times!) Weird. Gail Schlentz prasannakumar Reddy Greenhorn Posts: 5 posted 6 years ago Hi, why the compiler compliance level is changed to 1.4? if you are running your application in 1.5?? Please clarify me. thanks, Prasanna Peter Johnson author Bartender Posts: 5856 7 I like... posted 6 years ago The Eclipse compiler compliance level appears to have nothing to do with the version of the JDK you are using. But you can change it globally by going to Windows | Preference | Java | Compiler. Once you change it there any new projects you create will inherit that setting. JBoss In Action prasannakumar Reddy Greenhorn Posts: 5 posted 6 years ago Hello, Change your keyword name from enum to some thing else like enum
stories Forum Controls Reply to this Thread Search Forum Back to Thread List Whos Online: 156 guest(s), 0 user(s). More info » Spotlight Features Read the Spotlight Archives Replies: 4 - Pages: 1 Reply "Enum cannot be resolved", "Enum is not generic" compiler errors At 8:41 PM on Apr 2, 2008, Robert Dodier wrote: Hello, I am attempting to build (with Eclipse) a project which successfully builds with ant + javac 1.5.0. In a file which has some enums, I get some error messages, "java.lang.Enum cannot be resolved", "Enum is not generic". I have looked at the project properties and the project property viewer shows that Compiler compliance level, Generated .class files compatibility, and Source compatibility are all set to "5.0". Are there some other properties I should look at? There are multiple 1.5.0xxx JDK's on the development box and no 1.4 or other JDK's. Sorry if this on is a faq, just point me in the direction of the standard answer, thanks. Robert Dodier 4 replies so far ( Post your own) Reply 1. At 9:06 PM on Apr 2, 2008, Ed Merks wrote: Re: "Enum cannot be resolved", "Enum is not generic" compiler errors Robert, Despite you assurances that there are no 1.4 JDKS on your development box, it does sound like the JRE being used by Eclipse is a 1.4 JRE. Check carefully in Window->Preferences->Java->Installed JREs where the JRE that's being used is coming from... Robert Dodier wrote: > Hello, > > I am attempting to build (with Eclipse) a project which > successfully builds with ant + javac 1.5.0. > > In a file which has some enums, I get some error messages, > "java.lang.Enum cannot be resolved", "Enum is not generic". > > I have looked at the project properties and the project > property viewer shows that Compiler compliance level, > Generated .class files compatibility, and Source compatibility > are all set to "5.0". Are there some other properties > I should look at? > > There are multiple 1.5.0xxx JDK's on the development box > and no 1.4 or other JDK's. > > Sorry if this on is a faq, just point me in the direction > of the standard answer, thanks. > > Robert Dodier > > Reply 1. At 9:06 PM on Apr 2, 2008, Ed Merks wrote: Re: "Enum cannot be resolved", "Enum is not generic" compiler errors Robert, Despite you assurances that there are no 1.4 JDKS on your development box, it does sound like the JRE being used by Eclipse is a 1.4 JRE. Check carefully in Window->Preferences->Java->Installed JREs where the JRE that's being used is coming from... Robert Dodier wrote: > Hello, > > I am attempting to build