Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Problem with enum
Problem with enum [message #637203] Thu, 04 November 2010 14:58 Go to next message
Torbjørn Knutsen is currently offline Torbjørn KnutsenFriend
Messages: 7
Registered: September 2010
Junior Member
Hi,

I'm trying to create an enum in a java file, but Eclipse acts out..

Some test code:

class someclass {
enum ape {
chimp, spidermonkey
}
}

I get the error message "enum cannot be resolved to type". As far as I could read, this way of defining enums should work with Java 1.5 and newer.

My compiler compliance level is set to 1.6 (tried 1.5 and 1.4 as well, no luck). Installed JRE is java-6-openjdk.

This test-code compiles without error, so must be something wrong with eclipse..
Re: Problem with enum [message #637230 is a reply to message #637203] Thu, 04 November 2010 16:37 Go to previous messageGo to next message
Mauro Molinari is currently offline Mauro MolinariFriend
Messages: 285
Registered: July 2009
Senior Member
Il 04/11/2010 15:59, Torbjørn Knutsen ha scritto:
> Hi,
>
> I'm trying to create an enum in a java file, but Eclipse acts out..
>
> Some test code:
>
> class someclass {
> enum ape {
> chimp, spidermonkey
> }
> }
>
> I get the error message "enum cannot be resolved to type". As far as I
> could read, this way of defining enums should work with Java 1.5 and newer.
> My compiler compliance level is set to 1.6 (tried 1.5 and 1.4 as well,
> no luck). Installed JRE is java-6-openjdk.

What do you mean by "installed JRE is java-6-openjdk"? Does your Java
project have a JRE System Library associated which comes from Java 6?
Look at the Java Build Path of that project (Libraries tab).

I have no problem at creating a Java file with your code.

Mauro.
Re: Problem with enum [message #637236 is a reply to message #637203] Thu, 04 November 2010 16:49 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
On 11/4/10 7:59 AM, Torbjørn Knutsen wrote:
> Hi,
>
> I'm trying to create an enum in a java file, but Eclipse acts out..
>
> Some test code:
>
> class someclass {
> enum ape {
> chimp, spidermonkey
> }
> }
>
> I get the error message "enum cannot be resolved to type". As far as I
> could read, this way of defining enums should work with Java 1.5 and newer.
> My compiler compliance level is set to 1.6 (tried 1.5 and 1.4 as well,
> no luck). Installed JRE is java-6-openjdk.
>
> This test-code compiles without error, so must be something wrong with
> eclipse..

That conclusion seems a bit extreme, given the number of Eclipse users
who are happily working with enums at any given moment.

More likely, there is a problem with your configuration, and either you
are running Eclipse with a JDK that does not let it support Java 5
features, or your project is not correctly configured.

What version of Eclipse are you using?

What version of the JRE are you running Eclipse with? (This may not be
the same as what you are compiling against.)

Are you able to use a Sun (/Oracle) JDK, or IBM, or JRockit? Eclipse is
not tested on openjdk so I have no idea whether that's an issue or not.

In your project properties, you say you have the compiler compliance set
to 1.6; do you also have the "Use default compliance settings" box checked?
Re: Problem with enum [message #639133 is a reply to message #637203] Mon, 15 November 2010 12:01 Go to previous messageGo to next message
Torbjørn Knutsen is currently offline Torbjørn KnutsenFriend
Messages: 7
Registered: September 2010
Junior Member
I'm using Eclipse version 3.5.2.

The installed JDK is found in window->preferences->java->installed JREs, and is java-6-openjdk.

I have checked the default compliance settings box, but there is an entry called "Disallow identifiers called 'enum' which is set to "Error", which i can't change.

I actually see now that i can change it if i set source compatability to 1.4, and uncheck the default compliance box. Still does not fix the problem though.
Re: Problem with enum [message #639162 is a reply to message #637203] Mon, 15 November 2010 13:16 Go to previous message
Torbjørn Knutsen is currently offline Torbjørn KnutsenFriend
Messages: 7
Registered: September 2010
Junior Member
Fixed it, had to set the compiler in the properties for the project, not just in the preferences..
Previous Topic:Problem connecting to MySql
Next Topic:ERROR: Unable to open class file
Goto Forum:
  


Current Time: Fri Mar 29 07:10:45 GMT 2024

Powered by FUDForum. Page generated in 0.03195 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top