Building a jar with Ant

J

jaja

Hi there,
I am trying to build my jar using the Ant facility.
I wrote build.xml and build.properties files and executed build.cmd
file.

I got the following error:

"complie:
[echo] Compiling java files
[echo]
[javac] Compiling 38 source files to C:\Dev_Env\...\build\output

BUILD FAILED
C:\Dev_Env\...\build\build.xml:98: The following error occurred while
executing this line:
C:\Dev_Env\...\build\build.xml:54: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK"

My current JAVA_HOME is set to C:\j2sdk which do exists.
My current ANT_HOME is set to c:\ant

This is the compilation segment in build.xml:
----------------------------------
<target name="complie" depends="init">
<echo message="Compiling java files">
</echo>
(line 54) <javac srcdir="${java_src}" destdir="${dest}" source="1.4">
<classpath>
<fileset dir="${dest}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
------------------------------------

It seems to me that for some reason it takes a wrong jdk path but I
can't understand why and from where.

Any help will be appreciated.
Thanks!
 
J

jaja

Hi there,
I am trying to build my jar using the Ant facility.
I wrote build.xml and build.properties files and executed build.cmd
file.

I got the following error:

"complie:
[echo] Compiling java files
[echo]
[javac] Compiling 38 source files to C:\Dev_Env\...\build\output

BUILD FAILED
C:\Dev_Env\...\build\build.xml:98: The following error occurred while
executing this line:
C:\Dev_Env\...\build\build.xml:54: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK"

My current JAVA_HOME is set to C:\j2sdk which do exists.
My current ANT_HOME is set to c:\ant

This is the compilation segment in build.xml:
----------------------------------
<target name="complie" depends="init">
<echo message="Compiling java files">
</echo>
(line 54) <javac srcdir="${java_src}" destdir="${dest}" source="1.4">
<classpath>
<fileset dir="${dest}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
------------------------------------

It seems to me that for some reason it takes a wrong jdk path but I
can't understand why and from where.

Any help will be appreciated.
Thanks!

By the way, I just saw that even in the ant.bat file it is set
JAVA_HOME=C:\j2sdk which seems to be ok to my knowledge...
 
J

jaja

Hi there,
I am trying to build my jar using the Ant facility.
I wrote build.xml and build.properties files and executed build.cmd
file.
I got the following error:
"complie:
[echo] Compiling java files
[echo]
[javac] Compiling 38 source files to C:\Dev_Env\...\build\output
BUILD FAILED
C:\Dev_Env\...\build\build.xml:98: The following error occurred while
executing this line:
C:\Dev_Env\...\build\build.xml:54: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK"
My current JAVA_HOME is set to C:\j2sdk which do exists.
My current ANT_HOME is set to c:\ant
This is the compilation segment in build.xml:
----------------------------------
<target name="complie" depends="init">
<echo message="Compiling java files">
</echo>
(line 54) <javac srcdir="${java_src}" destdir="${dest}" source="1.4">
<classpath>
<fileset dir="${dest}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
------------------------------------
It seems to me that for some reason it takes a wrong jdk path but I
can't understand why and from where.
Any help will be appreciated.
Thanks!

By the way, I just saw that even in the ant.bat file it is set
JAVA_HOME=C:\j2sdk which seems to be ok to my knowledge...- -

- -

Ok, I found at least a workaround:
I copied the file tools.jar from c:\j2sdk\lib to the ant lib directory
and build was successful.
 
R

Roedy Green

My current JAVA_HOME is set to C:\j2sdk which do exists.

That sounds like a pretty old Java. Try using the current version.

JAVA_HOME=E:\program files\java\jdk1.6.0_02
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top