Ant build failed, "[javac] javac: invalid target release: 7"

UPDATE: See permission here.

Thank you all for your help!


I get an error when trying to compile a project with Ant that asks for "[javac] javac: invalid target release: 7" and causes the build to fail.

I am running javac version 1.7.0_40 on a Mac OSX Mavericks machine. Ant version: Apache Ant (TM) version 1.8.3, compiled on February 26, 2012.

Only when trying to compile with Ant does the problem arise. Compiling individual files in a project using javac on the command line works correctly (with the following command):

javac -d /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils -classpath /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils:/Users/username/git/appinventor-sources/appinventor/lib/guava/guava-14.0.1.jar -target 7 -encoding utf-8 -g:lines,vars,source -source 7 common/src/com/google/appinventor/common/utils/*

The build-common.xml file points to javac:

<attribute name="source" default="7"/>
<attribute name="target" default="7"/>

: https://github.com/cdlockard/appinventor-sources/blob/master/appinventor/build-common.xml

Java .

Per ,

executable="/usr/bin/javac"

build-common.xml, , Java, .

:

init:

CommonUtils:
[javac] Compiling 1 source file to /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils
[javac] javac: invalid target release: 7
[javac] Usage: javac <options> <source files>
[javac] use -help for a list of possible options

BUILD FAILED
/Users/username/git/appinventor-sources/appinventor/build.xml:16: The following error occurred while executing this line:
/Users/username/git/appinventor-sources/appinventor/build-common.xml:318: The following error occurred while executing this line:
/Users/username/git/appinventor-sources/appinventor/common/build.xml:42: The following error occurred while executing this line:
/Users/username/git/appinventor-sources/appinventor/build-common.xml:120: Compile failed; see the compiler error output for details.

Ant :

[javac] Compiling 1 source file to /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils
[javac] Using modern compiler
[javac] Compilation arguments:
[javac] '-d'
[javac] '/Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils'
[javac] '-classpath'
[javac] '/Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils:/Users/username/git/appinventor-sources/appinventor/lib/guava/guava-14.0.1.jar'
[javac] '-target'
[javac] '7'
[javac] '-encoding'
[javac] 'utf-8'
[javac] '-g:lines,vars,source'
[javac] '-verbose'
[javac] '-source'
[javac] '7'
[javac] 
[javac] The ' characters around the executable and arguments are
[javac] not part of the command.
[javac] File to be compiled:
[javac]     /Users/username/git/appinventor-sources/appinventor/common/src/com/google/appinventor/common/utils/package-info.java
[javac] javac: invalid target release: 7
[javac] Usage: javac <options> <source files>
[javac] use -help for a list of possible options
  [ant] Exiting /Users/username/git/appinventor-sources/appinventor/common/build.xml.

? .

+3
2

, Ant Java 1.6 ( ), $JAVA_HOME , 1.7. $JAVA_HOME, .bash_profile:

export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home'

, .

, Java Ant , :

Detected Java version: 1.6 in: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

, :

- , Ant "" javac .xml, fork yes. fork "no", , , "", "" .

- Mac javac /usr/bin/javac.

which javac

, , , ,

javac -version

. , Ant javac PATH, JAVA_HOME.

!

+5

project.properties

javac.source=1.8
javac.target=1.8

to

javac.source=1.7
javac.target=1.7
+1

All Articles