Hello Eric,
--- "Sun, Eric" <[EMAIL PROTECTED]> wrote:
> I am new to Ant. I have two questions:
> 1. How to include all needed library in the final
> jar file so that when
> run the application, no any other jar library is
> needed?
One way to do it is to <unjar>[1] all other jars and
to <jar>[2] them again with your application:

<unjar src="lib1.jar" dest="${lib1.classes}"/>
<unjar src="lib2.jar" dest="${lib2.classes}"/>
...
<!-- After they are all unjarred, jar them here again
with your own classes-->
<jar destfile="yourApp.jar">
  <fileset dir="${lib1.classes}"/>
  <fileset dir="${lib2.classes}"/>
  ...
  <fileset dir="your_compiled_classes">
</jar>

I myself think that it is a tedious way to include the
classes of all the libs you use in the jar of your
application. Instead I would prefer using manifest
attribute of <jar> task:
<jar destfile="yourApp.jar">
  <fileset dir="your_compiled_classes">
  <manifest>
    <attribute name="Main-Class"
value="yourApp.yourMainClass"/>
    <attribute name="Class-Path" value="lib1.jar
lib2.jar ..."/>
  </manifest>
</jar>

> 2. How to build a java executable on Windows XP and
> Linux with Ant?
JSmooth builds exe files from jar files. I read some
positive comments about it, but I never used, so use
it on your responsibility.
As for building native executables on Linux, I use GNU
Compiler for Java[4]. It can build native executables
(actually both for Linux and Windows) if it is passed
the relevant options.

> 
> Can anybody tell me how to do that? Or point where
> to get the info?

HTH Ivan
[1]http://ant.apache.org/manual/CoreTasks/unzip.html
[2]http://ant.apache.org/manual/CoreTasks/jar.html
[3]http://jsmooth.sourceforge.net/
[4]http://gcc.gnu.org/java/
> 
> Thanks in advance.
> 
> Eric



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to