This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm running Tiger (Java 5.0) on Tiger (Mac OS 10.4). Initially, I had some difficulty setting the "CurrentJDK" alias to the new version of Java (the 1.5.0 directory). This was solved as described here:
But now I've installed Eclipse 3.0.2, and it works fine until I attempt to compile Java 5.0 code (for example, autoboxing "Integer i = 7;"). When I do this, it's apparent that Eclipse is using a pre-1.5 compiler. So how do I configure Eclipse to use 1.5.0?
I've looked around in Eclipse (which I'm admittedly not very familiar with), but couldn't find any way to set this. The config.ini file in the Eclipse/configurations folder doesn't seem to store this variable.
My .bash_profile has JAVA_HOME set to /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin.
On the Eclipse Console toolbar (above the actual output area), it displays "<terminated> ... /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java" -- whether or not the code successfully compiles and runs (i.e., whether it's new Java 5.0 code that fails, or a safe Hello World that runs). So it seems that Eclipse is trying to use the .bash_profile variable, but terminates it and moves to a prior version instead.
With Java 5.0 code, the error message is consistent with a pre-1.5 compiler: "Type mismatch: cannot convert from int to Integer"
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
what issues are you having exactly? These are described in my original post at the top. Basically, Eclipse displays "<terminated> ... /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java" on the Console toolbar whenever I compile. If the code contains Java 1.5 features (e.g., autoboxing), then pre-1.5 compiler errors result.
Is your project definitely set up to use the correct Java run time? This is exactly my question: What do I need to do to set it up for the correct compiler and runtime?
I had concluded -- perhaps incorrectly -- that Java 1.5 for Mac is not supported by Eclipse 3.1, so any help would be greatly appreciated!
Okay, I've got it -- Java 5.0 is now working in Eclipse!
As described above, autoboxing simply wasn't working. So I tried some other 5.0 code (instances of Scanner, StringBuilder, etc.), and these worked. Then I tried the new "for each" loop, and this produced a warning icon that said I needed to change "workspace compliance settings to 5.0" or "project compliance settings to 5.0."
Under "Preferences/Java/Compiler," I found the following settings...
Compiler compliance level: 1.4
Generated .class files compatability: 1.2
Source compatibility: 1.3
I changed each of these to 5.0, and now everything seems to work!
(I really thought this was an issue unique to Java 5.0 on the new Mac OS, but it turned out to be my lack of familiarity with Eclipse. :roll: ) [ May 12, 2005: Message edited by: marc weber ]
Well, I did the same thing (setting up the compiler to point to JDK 1.5) and whereas the java.util.Arrays and java.util.queue (both from JDK 1.5 - Tiger) worked in Eclipse 3.0.1 running on OS X - Tiger, eclipse didn't understand Generics <SomeType>...
Has anyone successfully written generics in Eclipse on OS X 10.4? And if yes, what version of Eclipse was this person using...
Eclipse uses it's own compiler to build projects. This allows it to do many things (such as run a project that has compile errors, at least to some extent) that it could not otherwise do. Therefore you must have a version of eclipse that supports the compilation of the new Java 1.5 features.
Eclipse 3.0.x does not support any of the new language features for Java 1.5, but if you have the 1.5 jdk installed it will see the new classes as they are on the classpath.
Eclipse 3.1 is now in it's last milestone build, M7, and will have final release around the end of June (I think).
Eclipse allows you to specify, per project, what compiler you want to use as far as Java version compatability goes. You can set the project to use the 'workspace settings'.
Generated .class files compatability: refers to the lowest version of the JRE you want your compiled files to be able to run against. By default this is set at 1.2 so you can write and compile things in 1.5 and somebody running 1.2 can use them. I'm not sure how this works as far as the new classes goes, I think if you use any new classes the end user would need a version with those new classes in it.
Source compatibility: refers to what Java version will be used to compile your source. This would need to be set to 1.5 in order for the new features to be available.
If I've missed anything or gotten anything wrong, let me know.