File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse compliance level problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse compliance level problem" Watch "Eclipse compliance level problem" New topic
Author

Eclipse compliance level problem

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

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?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

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?


JBoss In Action
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

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

Joined: May 14, 2008
Posts: 5843
    
    7

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

Joined: Jul 26, 2007
Posts: 10523
    
    9

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

Joined: Aug 16, 2005
Posts: 14351
    
  22

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

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

Joined: May 14, 2008
Posts: 5843
    
    7

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

Joined: Jul 26, 2007
Posts: 10523
    
    9

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Eclipse compliance level problem