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 10:58 Go to next message
Torbjørn Knutsen is currently offline Torbjørn Knutsen
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 12:37 Go to previous messageGo to next message
Mauro Molinari is currently offline Mauro Molinari
Messages: 278
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 12:49 Go to previous messageGo to next message
Walter Harley is currently offline Walter Harley
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 07:01 Go to previous messageGo to next message
Torbjørn Knutsen is currently offline Torbjørn Knutsen
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 08:16 Go to previous message
Torbjørn Knutsen is currently offline Torbjørn Knutsen
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:Help about JST
Goto Forum:
  


Current Time: Fri Aug 01 10:12:34 EDT 2014

Powered by FUDForum. Page generated in 0.01829 seconds