Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem in ant build invalid target release

Tags:

java

ant

problem in ant build

[javac] Compiling 86 source files to F:\XXX\classes
    [javac] javac: invalid target release: 1.6
    [javac] Usage: javac <options> <source files>
    [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 <path>          Specify where to find user class files
    [javac]   -cp <path>                 Specify where to find user class files
    [javac]   -sourcepath <path>         Specify where to find input source files
    [javac]   -bootclasspath <path>      Override location of bootstrap class files
    [javac]   -extdirs <dirs>            Override location of installed extensions
    [javac]   -endorseddirs <dirs>       Override location of endorsed standards path
    [javac]   -d <directory>             Specify where to place generated class files
    [javac]   -encoding <encoding>       Specify character encoding used by source files
    [javac]   -source <release>          Provide source compatibility with specified release
    [javac]   -target <release>          Generate class files for specific VM version
    [javac]   -version                   Version information
    [javac]   -help                      Print a synopsis of standard options
    [javac]   -X                         Print a synopsis of nonstandard options
    [javac]   -J<flag>                   Pass <flag> directly to the runtime system


BUILD FAILED

ant source and target to 1.6 en variable path to jdk 1.6

like image 991
Gopal Avatar asked Feb 10 '11 10:02

Gopal


1 Answers

You use a compiler that cannot compile with -target 1.6 (javac: invalid target release: 1.6). Are you sure you use the JDK 1.6? Maybe a JDK 1.5 is installed and used by ant. Check the used Java-version with adding following line to your target (at the beginning):

<echo message="Using Java version ${ant.java.version}."/>

It outputs the Java-version used by Ant.

You can set the compiler to use a different Java-version. You have to use the fork-attribute to use an external javac and specify which one you want:

<javac srcdir="${src}"
         destdir="${build}"
         fork="yes"
         executable="/opt/java/jdk1.6/bin/javac"
  />

Read the documentation of the javac-task for details.

like image 125
Mnementh Avatar answered Sep 20 '22 11:09

Mnementh