raja
raja

Reputation: 4193

Doubt in build.xml file in Apache-Ant1.6.5

I have used Collections in my code with Generics. When try to compile that java file in build.xml, its showing error at generics and its saying its not a statement. I am using Apache-Ant-1.6.5 and i have installed JDK 1.5 only . I know generic will support in jdk1.5 but its showing error. The below is the error i am getting for the code

code :

Map<String, String> inputconfigmap = 
    new LinkedHashMap<String, String>();

Exception :

compile:
    [mkdir] Created dir: D:\GenericPreProcessor\Source\classes
    [javac] Compiling 49 source files to D:\GenericPreProcessor\Source\classes
    [javac] D:\GenericPreProcessor\Source\src\com\dnb\genericpreprocessor\fileprocessor\FixedLength
FileProcessor.java:187: not a statement
    [javac] Map<String, String> inputconfigmap = 
                new LinkedHashMap<String, String>();

I did as per your suggestion but i got the following in the console.

Console :
D:\GenericPreProcessor\Source>ant
Buildfile: build.xml
[echo] JVM version is 1.5
[echo] Target compilation is ${ant.build.javac.target}

clean:
[delete] Deleting directory D:\GenericPreProcessor\Source\classes

cleanJar:

compile:
[mkdir] Created dir: D:\GenericPreProcessor\Source\classes
[javac] Compiling 49 source files to D:\GenericPreProcessor\Source\classes
[javac] javac: invalid target release: 1.5
[javac] Usage: javac
[javac] where possible options include:
[javac] -g Generate all debugging info
[javac] -g:none Generate no debugging info
[javac] -g:{lines,vars,source} Generate only some debugging info
[javac] -nowarn Generate no warnings
[javac] -verbose Output messages about what the compiler is doing
[javac] -deprecation Output source locations where deprecated APIs are used
[javac] -classpath Specify where to find user class files
[javac] -sourcepath Specify where to find input source files
[javac] -bootclasspath Override location of bootstrap class files
[javac] -extdirs Override location of installed extensions
[javac] -d Specify where to place generated class files
[javac] -encoding Specify character encoding used by source files
[javac] -source Provide source compatibility with specified release
[javac] -target Generate class files for specific VM version
[javac] -help Print a synopsis of standard options

BUILD FAILED

Upvotes: 0

Views: 1496

Answers (5)

toolkit
toolkit

Reputation: 50227

Have you tried explicitly setting the source and target attributes for your javac task?

<target name="compile">
    <javac .....
        source="1.6"
        target="1.6" />
</target>

Upvotes: 2

tehvan
tehvan

Reputation: 10369

Are you using double angle brackets (<< and >>)? They should be single ones as kgiannakakis showed:

Map<String, String> inputconfigmap  = new LinkedHashMap<String, String>();

Upvotes: 0

Vinze
Vinze

Reputation: 2539

Maybe you can check the version of your compilator with :

<echo>JVM version is ${ant.java.version}</echo>
<echo>Target compilation is ${ant.build.javac.target}</echo>

And you can add <property name="ant.build.javac.target" value="1.5" /> to force the compiler to use Java 5 compliance... This property is the default target from ant 1.7, for ant 1.6 I think you must add target="${ant.build.javac.target}" to your javac target.

Upvotes: 1

Drejc
Drejc

Reputation: 14286

Try

Map<?, ?> inputconfigmap = new LinkedHashMap<?, ?>(); 

Upvotes: 0

kgiannakakis
kgiannakakis

Reputation: 104168

You need to define the type of the Map, i.e:

Map<String, String> inputconfigmap  = new LinkedHashMap<String, String>(); 

Upvotes: 0

Related Questions