• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse compliance level problem

 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse 3.3.0 with JDK1.6.0_07.
For some reason we decided to bring down the level to 1.4.2
I changed the eclipse compliance settings to the "compiler compliance level 1.4"

In my code I am using which was definitely added in 1.6. Surprisingly Eclipse is not giving me an error on this line.
Do I need to change any more settings?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you change the compliance settings? Globally in Window > Preferences? Or in Project > Properties?

In Project > Properties, what are the settings for Java Compiler?
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Project->Properties
Enable project specific settings : checked
Compiler compliance level 1.4
Use default compliance settings : checked
Generated .class file compatibility 1.2
Source compatibility 1.3
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Package Explorer, which JRE is referenced for your project? If that is still 1.6, you can change it in the Project Properties under Java Build Path, the Libraries tab. Of course, you would then need a 1.4.2 JDK installed.
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Johnson:
.. Of course, you would then need a 1.4.2 JDK installed.


Yes it is still pointing to 1.6.
I was under the impression, that the "compliance level" stuff would internally work out the "-source" and "-target" flags and build accordingly. If I need to install multiple version, it defeats the purpose of having the "compliance level" functionality

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maneesh Godbole:
I was under the impression, that the "compliance level" stuff would internally work out the "-source" and "-target" flags and build accordingly.

That's exactly what it does. But those settings (in Eclipse as well as on the command line with javac) only check that you're not using language features that were added in Java 5 or 6. You still have to make sure it looks at the right version of the JVM libraries. If you want to develop for 1.4, you'll need to install 1.4 and make Eclipse use it for your project.
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.
I (reluctantly) installed 1.4 and configured eclipse to use it. Now I get all expected errors.

Thanks Peter and Jesper for your help.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By setting the compliance level to 1.4.2, I think that Eclipse will tag annotations (and other new 1.5 and 1.5 Java language features) as errors, but as Jesper pointed out as long as you are using the 1.6 JDK library, Eclipse will not mark classes or methods introduced in 1.5 or 1.6 as errors.
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. That was what my problem was. I was getting errors for @override annotations and Generics but not for methods.
However, now that I have configured 1.4.2, it is correctly identifying the methods.

Thanks once again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic