Actually there should be no tools.jar in both locations. ANT will
automatically use tools.jar from JDK specified by JAVA_HOME. Please add
a target to dump all properties and run it to see what was actually
executed.
There is also a possibility that <javac> will work with fork="true".
- Alexey.
Rhino wrote:
What version of tools.jar is the correct one for Ant 1.6.5? How can I
tell whether I have the right version: by the version number? the size
of the file? the timestamp on the file?
Rhino
----- Original Message ----- From: "Alexey N. Solofnenko"
<[EMAIL PROTECTED]>
To: "Ant Users List" <user@ant.apache.org>
Sent: Thursday, December 15, 2005 8:08 PM
Subject: Re: Compiling enums in Ant 1.6.5
Is it possible that you have old tools.jar somewhere on your
CLASSPATH or in your ANT's installation directory?
- Alexey.
Rhino wrote:
----- Original Message ----- From: "Rhino" <[EMAIL PROTECTED]>
To: "ant-user" <user@ant.apache.org>
Sent: Thursday, December 15, 2005 5:36 PM
Subject: Compiling enums in Ant 1.6.5
Can the <javac> task in Ant 1.6.5 compile a typesafe enum when
using the 'modern' compiler? If yes, how do I persuade it to do so?
If no, is there any workaround or will I just have to compile the
enum separately and include it in my build manually?
Here is my task:
<target name="compile" description="Compile the Java code.">
<javac srcdir="${common.src}" destdir="${common.bin}"
compiler="modern" fork="yes"
verbose="no" debug="on" debuglevel="lines,vars,source"
deprecation="yes"
description="Compile the code in the common package.">
<patternset refid="ps.common"/>
</javac>
</target>
Here is the (relevant) output from the build, which had both the
-debug and -verbose switches on:
[javac]
E:\eclipse\3.0.1\eclipse\workspace\Common\src\ca\maximal\common\Palette.java:19:
'class' or 'interface' expected
[javac] public enum Palette {
[javac] ^
For what it's worth, I tried adding the source="1.5" parameter to
the target and got the message "javac: invalid source release:
1.5". My JAVA_HOME environment variable is set to D:\Program
Files\Java\jre1.5.0_06, otherwise I'd suspect that I was pointing
at a 1.4 (or earlier) compiler.
Can anyone shed some light on how I can get Ant to compile this enum?
I've solved my problem, although I'd like some guidance on why I had
to resort to this to make it work.
Shortly after clicking on 'Send', I decided to look in my
JAVA_HOME\bin directory to verify that javac.exe was there. It
_wasn't_ there and I suddently remembered why: it was a JRE, not a
JDK, so naturally no compiler was present!
[Hmmm, I just noticed Alexey's reply to my question; Alexey saw the
problem before I could finish this note!]
Anyway, I changed JAVA_HOME to point to the 1.5.0_06 JDK instead of
the JRE. This was in d:\Program Files\Java\jdk1.5.0_06.
I ran the javac task again, with the 'source' parameter included, as
shown here:
<target name="compile" description="Compile the Java code.">
<javac srcdir="${common.src}" destdir="${common.bin}"
compiler="modern" fork="yes"
verbose="no" debug="on" debuglevel="lines,vars,source"
deprecation="yes"
source="1.5"
description="Compile the code in the common package.">
<patternset refid="ps.common"/>
<classpath
path="E:\eclipse\3.0.1\eclipse\workspace\Common\bin\ca\maximal\common\utilities\LocalizationUtils"/>
</javac>
</target>
and again got the error message: javac: invalid source release: 1.5
Why??
I amended the task to add the 'executable' parameter (compiler.path
was set to d:\Program Files\Java\jdk1.5.0_06\bin\javac):
<target name="compile" description="Compile the Java code.">
<javac srcdir="${common.src}" destdir="${common.bin}"
compiler="modern" fork="yes"
verbose="no" debug="on" debuglevel="lines,vars,source"
deprecation="yes"
executable="${compiler.path}" source="1.5"
description="Compile the code in the common package.">
<patternset refid="ps.common"/>
<classpath
path="E:\eclipse\3.0.1\eclipse\workspace\Common\bin\ca\maximal\common\utilities\LocalizationUtils"/>
</javac>
</target>
This time my Palette enum compiled fine.
However, I have some followup questions: Why did I have to add the
'executable' parameter to make this work? Shouldn't Ant have seen
the correct compiler by virtue of the fact that I had corrected the
JAVA_HOME environment variable to point to a JDK? I did a 'set' at
the command prompt to verify that the amended JAVA_HOME was indeed
visible before doing the compiles.
For what it's worth, Alexey's caution about the spaces in my
JAVA_HOME (...Program Files...) value struck me as a potential cause
of the problem so I: closed Eclipse; uninstalled the JDK;
reinstalled it in D:\Java; changed JAVA_HOME to D:\Java\jdk1.5.0_06;
restarted Eclipse; modified the compiler.path property to
d:\Java\jdk1.5.0_06\bin\javac and ran the build again.
The result was exactly the same: if I omitted the 'executable'
parameter and used the 'source="1.5"' parameter, I got the 'javac:
invalid source release: 1.5' error. If I added
'executable="${compiler.path}", the compile worked fine.
How do I get the javac task to work _with_ the 'source="1.5"'
parameter but *without* specifying the 'executable' parameter?
Rhino
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/200 - Release Date:
14/12/2005
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]