Xcode: 'Generics are not supported in -source 1.3' compiler error?

By : VeePee
Source: Stackoverflow.com
Question!

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.

By : VeePee


Answers

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".



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

By : user7305


This video can help you solving your question :)
By: admin