wood burning stoves 2.0*
The moose likes Java in General and the fly likes eclipse 3.0 and java 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "eclipse 3.0 and java 5" Watch "eclipse 3.0 and java 5" New topic
Author

eclipse 3.0 and java 5

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
why eclipse doesnt work (or compile, not sure) properly with java 5?


java amateur
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
try 3.1 if you want eclipse to recognize java 5 features
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Note that 3.1 is still in beta. You can download it from the top 10 downloads area of the Eclipse site.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
Miguel,

I did a small (sample) project in Eclipse 3.0 using JDK 1.5, it seemed to work fine. What exactly are the issues you are facing?


Regards,
Saket
[ March 16, 2005: Message edited by: Saket Barve ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
I wonder how you got Eclipse 3 to recognise any of the new language constructs.
I wonder even more how you got the compiler in Eclipse 3.0 to generate version 49 classfiles (which is the 1.5 format).

Most likely you think that because you can run Eclipse 3.0 on a machine on which JDK 5.0 is installed they work togeter but they don't, Eclipse 3.0 will only recognise J2SDKSE 1.4 and earlier language constructs and will only generate classfiles to version 48 or earlier (which will run on a 5.0 JVM of course as the runtimes are fully backwards compatible between 1.4 and 5.0).


42
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
pardon my ignorance, but what are version 49 classfiles?
Fintan Conway
Ranch Hand

Joined: Apr 03, 2002
Posts: 141
Hi all,

I am running Eclipse 3.1M3. The way that I set up an Eclipse project to be compatible with Java 5 (or 1.5 if you prefer) is to go into the project properties and select 'Java Compiler' then click the "Configure Workspace Settings" button.

This gives you a list of options which you can configure for the compiler.

For Java version settings select the 'Compiler and Compliance' tab.

The first drop down box is for "Compiler compliance level". This can be set to '5.0'. There are other option you could play around with but this setting should be enough.

The other thing I do is check that Eclipse is using the correct (Java 5) compiler. Once you have clicked 'OK' on the Java Compiler options click on the 'Java Build Path' option from the list. This gives you a list of options that you can configure for building your java project.

Click on the tab called 'Libraries'. At a minimum there should be at least one item listed = "JRE System Library". In the square brackets after the name this should say "[Java 5]", if this says something like "[j2sdk1.4.2]" instead then you need to change this to use the Java 5 library (which is your java 1.5 - just remember java 5 = java 1.5).

Click on 'Add Library' button.
Select 'JRE System Library' from the list of options and Click 'Next'.
Select 'java 5' in the drop down box beside "Alternate JRE" and click 'Finish'.

If 'java 5' does not appear in the drop down list you will need to tell Eclipse where to go to find the Java 5 compiler (assuming that you have installed it). To do this click the 'Installed JREs..' button.

This brings you to a screen where you can delete, add or edit the Java run-times that Eclipse will search for. Click 'Add...'. Enter "Java 5" as the JRE name and browse for the 'JRE Home Directory' and point to where you have Java 5 installed. The 'Use default system libraries' checkbox should be ticked. Click 'OK'.

Java 5 should now appear on the list of Installed JREs. Tick the checkbox next to it. Click 'OK', Click 'Finish'.

In the list of libraries make sure that there is only 1 'JRE System Library'. If there is more than one highlight the one without "[Java 5]" and click remove. Repeat this until the only one remaining is 'JRE System Library [Java 5]'.

Hopefully this will work in Eclipse 3.0.

Regards,

Fintan
Reghu Ram Thanumalayan
Ranch Hand

Joined: Oct 21, 2003
Posts: 193
Hi,
Even i had executed some sample J2SE 5.0 code using Eclipse 3.0 and JDK 5.0 beta. It worked fine.

Jeroen Wenting, what do you mean by this ?
I wonder how you got Eclipse 3 to recognise any of the new language constructs.


That eclipse 3.0 IDE will show errors on using the new java 5 constructs ? Can you elaborate on version 48, 49 files ?


Cheers,<br />Reghu Ram T<br /> <br />SCJP 1.4 - 98 %, SCBCD 1.3 - 94 %, SCMAD 1.0 - 92 %
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
1.4 compilers (including the one in Eclipse 3.0) generate classfiles with version 48.x (x depending on the exact compiler version).
1.5 (5.0) compilers generate classfiles with version 49.0 (unless specifically told to generate an older format using the -target flag).

Eclipse 3.0 at all levels cannot work with 1.5 language constructs. This includes both the editor (which will simply show errors for everything it doesn't recognise as valid 1.4 code) and the compiler (which will fail on the same things).
Eclipse 3.1 adds the new features (with the level of support gradually going up in the different builds).

While you can add the 1.5 JRE to the runtime list, you cannot compile any code using the new language features so it will only ever run 1.4 compatible code.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
@Jeanne Boyarsky:
thanks for the link!

@Fintan Conway:
thanks a lot for your thorough tutorial
as soon as i install java5 i'll try it

At eclipse 3.0 release notes i found this:
Developing programs with J2SE 1.5
The Java tools do not yet fully support J2SE 1.5. You can run or debug programs against a 1.5 JRE, and safely compile 1.4 programs against 1.5 libraries (the Eclipse compiler tolerates them with the exception of covariance scenarios which are forbidden byJava Language Specification (JLS) 2nd edition). However, the Eclipse Java compiler and IDE are unable to handle source files containing uses of any of the new Java language features being added in 1.5 (generics, enhanced for loops, static imports, metadata annotations, varargs), which will be codified in the forthcoming JLS 3rd edition. An early preview of the full Eclipse support for J2SE 1.5 developed in parallel with 3.0, and is available from the Cheetah page. (bug 36938)


i just downloaded eclipse 3.1M5a; as i have a lot of downloaded plugins and features for eclipse 3.0, i wonder if its safe to simply paste 3.0 plugin's folder into 3.1 install folder?!
because release notes from 3.1 states at top:
These release notes have yet to be updated for the 3.1 development stream.
What follows are the 3.0.0 release notes.]

and also release notes say:
If you had installed additional features and plug-ins into your old Eclipse, you should re-install them in the new Eclipse

this being true means hours of internet downloading again...
[ March 16, 2005: Message edited by: miguel lisboa ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
I just copied my plugins (and associated features) over into the 3.1 folder structure (be sure to not override anything already there!).
If I remember correctly they all worked.

Did the same with my workspace, that worked too

And a few months later I switched to JBuilder 2005, which is far superior.
[ March 16, 2005: Message edited by: Jeroen Wenting ]
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
ok, that tranquilizes me, thank you
[ March 16, 2005: Message edited by: miguel lisboa ]
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
@Fintan Conway
i did it all and went ok
thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: eclipse 3.0 and java 5