Home > eclipse enum > enumeration error eclipse

Enumeration Error Eclipse

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or eclipse enum error posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss eclipse enum interface expected 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 takes eclipse enum formatting a minute: Sign up Can not compile enums in Eclipse up vote 14 down vote favorite 2 While trying to introduce enums in my Android project in Eclipse, I encountered with the following problem: Compiler says: The type java.lang.Enum cannot

Eclipse Enum Cannot Be Resolved To A Type

be resolved. It is indirectly referenced from required .class files The type Enum is not generic; it cannot be parameterized with arguments I work under Ubuntu 10.04 and use Eclipse v.3.5.2. Tried to use both Java 6 OpenJDK and Java 6 Sun, but without success. Can anybody help me to sort out with this issue? Here is the code: public class MyClass { public MyClass() { } ... enum MyEnum { CONST1, CONST2, CONST3; } } java eclipse enums share|improve this question enum cannot be resolved to a variable edited Sep 28 '10 at 8:44 Riduidel 16k443115 asked Sep 28 '10 at 8:38 Artem 169116 1 The code looks correct. The semicolon at the end is even optional. –Shervin Asgari Sep 28 '10 at 8:42 add a comment| 3 Answers 3 active oldest votes up vote 26 down vote Open the properties for the project, select the page "Java Compiler" and set the "Compiler Compliance level" to "1.5" or better. share|improve this answer edited Apr 24 '15 at 8:29 answered Sep 28 '10 at 8:41 Aaron Digulla 203k59362575 Is this a workaround or a solution? –Bobby Sep 28 '10 at 8:42 5 It is a necessity. –Thilo Sep 28 '10 at 8:44 Unfortunately I can't set "Compiler Compliance level" to "1.5" because I use @Override annotations for interfaces that is forbidden for 1.5 –Artem Sep 28 '10 at 8:52 1 @Artem: Sorry, I though it was clear that enums are allowed since Java 5 (which includes Java 6). Of course, they should work with Java 6 unless you have set the class or source compatibility to 1.4 or less. –Aaron Digulla Sep 28 '10 at 12:55 1 Thanks Aaron. it was definitely bug in Eclipse - probably because of other warning/errors –Artem Sep 28 '10 at 13:24 | show 6 more comments up vote 1 down vote Go to properties of project with the build error (right click > Properties) View the "Libra

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company enumeration cannot be resolved to a type jsp Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs

Java.util.enumeration Cannot Be Resolved

Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers,

Enum In Eclipse

just like you, helping each other. Join them; it only 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 http://stackoverflow.com/questions/3811012/can-not-compile-enums-in-eclipse 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); } 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 http://stackoverflow.com/questions/6544054/why-enum-could-not-be-resolved-in-java 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,32652240 asked Jul 1 '11 at 5:46 huahsin68 2,262105187 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,04811331 answered Nov 16 '12 at 11:15 stuhpa 13116 Man this have saved me twice. Nothing else I tried would get the environment to use 1.7 unless I used project specific settings. If I tried to use default setting (set to 1.7) it made no difference. I HAD to use the solution presented here. And that is with Kepler. –Brian Reinhold Nov 6 '15 at 0:22 add a comment| up vote 6 down vote the first compiles fine. Check your compiler level (should be at least 1.5) inteRface

folder Enter a source folder for the new enum. Either type http://help.eclipse.org/kepler/topic/org.eclipse.jdt.doc.user/reference/ref-wizard-enum.htm a valid source folder path or click Browse to select https://coderanch.com/t/104553/vc/Eclipse-enum-resolved a source folder via a dialog. The source folder of the element that was selected when the wizard has been started. Package Enter a package to contain the new enum. You can select either this option or the Enclosing Type option, below. eclipse enum Either type a valid package name or click Browse to select a package via a dialog. The package of the element that was selected when the wizard has been started. If a source folder was selected which contains exactly one package then that package is used. If the source folder does not contain cannot be resolved any package then the project name is used if it is a valid package name. Enclosing type Select this option to choose a type in which to enclose the new enum. You can select either this option or the Package option, above. Either type a valid name in the field or click Browse to select a type via a dialog. The type or the primary type of the compilation unit that was selected when the wizard has been started or Name Type a name for the new enum. Modifiers Select one or more access modifiers for the new enum. Either public, default, private, or protected (private and protected are only available if you specify an enclosing type) public Interfaces Click Add to choose interfaces that the new enum implements. Do you want to add comments? When selected, the wizard adds comments to the new enum where appropriate. Do not add comments File actions

This Site Careers Other all forums Forum: IDEs, Version Control and other tools Eclipse enum cannot be resolved Gail Schlentz Ranch Hand Posts: 634 posted 10 years ago I am in a new job & working 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 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 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 keyw

 

Related content

No related pages.