I installed Ubuntu Linux this morning and got java jdk 1.5.0_09 installed, along with Eclipse, and then I imported a project I've been working on into the Eclipse workbench.
All configuration is fine, as far as I can say.

My problem: The program I am working on uses the Enum. I've basically built the entire program around the use of Enum, and it's a huge program -- I can't change change it to work with simple constants. My problem is that enum is not working for me. Maybe this is a bug in _09, since in _06 it works wonderfully. In any case, I'm wondering why I may be encountering this problem, and how do I fix it. Thanks.

Here is a screen-shot of my problem:
[IMG]http://i12.photobucket.com/albums/a248/CudmoreMB/RandForums/Screenshot.png[/IMG]
The error says: Syntax error on token "enum", interface expected
And the second one says: Syntax error on token ",", delete this token
And then everywhere in the program I make reference to the enum: {ClassName} cannot be resolved

The enum class follows the simple format:

public enum ClassName {
	Var1,
	Var2,
	Var3,
	Etc
}

Dani AI

Generated

Good catch by — the error you saw happens when Eclipse is compiling with a pre‑Java‑5 language level so the parser doesn't recognize the new keyword. ’s followup confirms the problem was the project/workspace compliance setting. Below are practical, low‑risk steps and checks to make the fix stick and to avoid related pitfalls.

Window/Project settings to update

  • Workspace level: Window -> Preferences -> Java -> Compiler -> set "Compiler compliance level" to 1.5 (Java 5).
  • Project level (overrides workspace): Right‑click project -> Properties -> Java Compiler -> enable "Project specific settings" and pick 1.5.
  • Build path: Project -> Properties -> Java Build Path -> Libraries -> ensure the JRE System Library points to a Java 5/1.5 JRE (or the correct installed JDK).
  • After changing settings do Project -> Clean… then rebuild.

Quick command‑line and build tool checks

  • Verify what your shell uses: run
    java -version
    which java

    so you know the runtime on the system is at least 1.5. If you build with Ant, set the javac attributes explicitly and/or point Ant at the correct JDK:

    <javac srcdir="src" destdir="build" source="1.5" target="1.5" />

    If Maven is used, set maven‑compiler‑plugin source/target to 1.5.

Notes and gotchas
Eclipse uses its own compiler (ECJ) and honors the compliance level — changing the installed JDK alone may not change the language level. Also remember that compiling to 1.5 bytecode and running on an older JVM causes UnsupportedClassVersionError, so make sure both compile and runtime targets match. These extra checks make the enum problem disappear and prevent similar issues when moving projects between machines or Eclipse workspaces.

Recommended Answers

All 3 Replies

Check your compiler compliance settings. Most likely your project is configured for 1.4 language compliance.

Check your compiler compliance settings. Most likely your project is configured for 1.4 language compliance.

Ahh! Thank you very much!
I reliased today when I found the "This project is not JDK 1.5 compliant" error that my workspace wasn't configured for 1.5, so I checked workspace settings and, sure enough, the compiler compliance level was set to 1.4. You were exactly right! Thanks again.

-Matt

No problem. Just remember that Eclipse doesn't even make use of the JDK you've installed (except to run itself). It has its own built-in compiler (which is decent but not quite identical in what it does to the official one from Sun).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.