views:

2003

answers:

3

Hello everyone, just a quick question:

I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right after the line where I declare a new instance of an ArrayList:

dictionary = new ArrayList<String>();

I get the following error: generics are not supported in -source 1.3.

I was just wondering if anybody could offer advice as to what the problem might be. The same project compiles in Eclipse on the same machine. I'm running OSX 10.5.4, with Java 1.5.0_13.

Thank you.

A: 

Generics are introduced in Java 5, so you can't use generics with -source 1.3 option.

+8  A: 

Java support in Xcode is obsolete and unmaintained; it's the only bit of Xcode that still uses the "old" build system inherited from Project Builder. Even Apple suggests using Eclipse instead. For Java, both Eclipse and NetBeans work quite well on the Mac; if you want to try native Mac programming, use Objective-C and Cocoa, for which Xcode is fine.

That said, the problem is that javac is targeting Java 1.3, which doesn't have generics. You can modify the javac reference in the Ant buildfile (build.xml) as follows:

    <target name="compile" depends="init" description="Compile code">
 <mkdir dir="${bin}"/>
 <javac deprecation="on" srcdir="${src}" destdir="${bin}"
     source="1.3" target="1.2"

Change "source" and "target" to "1.5".

Nicholas Riley
Thanks for the quick and very complete answer, I had no idea about the lack of java support for Xcode. By the way, I did try to change the buildfile "source" and "target" to 1.5 but this only resulted in more compiler errors. I'll just stick to Eclipse :)
outsyncof
Intellij IDEA also works well on OS X.
tdavies
A: 

The build.xml file is placed in

/Developer/Library/XCode/Project Templates/Java/Java Tool/build.xml

(replace Java Tool with your own kind of project).

If you look for source="XX" target="YY" in line 30, and change XX and YY to your preferred values, things go better, much as explained in the previous posts.

Cheers,

Pieter