Problem in Executing a JAR file

In my project, I imported some packages from another project's class

folder. That class folder is available in my CLASSPATH and while executing my project from ECLIPSE editor, It's working well.

But, when I make it as a jar file and execute that in another machine, It throws an error "noClassDefFound", that class

belongs to another project, which I imported in my project.

That project contains Thousands of classes. But, I am using only few classes from that.

Can anyone please tell me, how to add those classes in to my jar file. And make my jar file flexible to execute at anywhere.

Thanks in advance.

--Kumaran

[671 byte] By [_Kumarana] at [2007-11-26 19:23:18]
# 1
genjar is a fine ant task that automatically includes the required classes into a jar, based on static dependencies. The only special thing you must tell it is the name of classes you use thru reflection. http://genjar.sourceforge.net/
dmbdmba at 2007-7-9 21:44:45 > top of Java-index,Java Essentials,Java Programming...
# 2

Thank you very much for your reply. I implemented the genjar in my project. But, while build my project, I am getting the following error.

========================================================

[genjar] Generating jar: E:\JMax\JMax.jar

BUILD FAILED

E:\JMax\build.xml:61: Unable to resolve: com/eg/util/FileWatcher.class

=========================================================

FileWatcher is my main class file.

My build.xml file is,

<?xml version="1.0"?>

<!DOCTYPE project []>

<project name="JUtar" basedir="." default="all">

<target name="init">

<property name="mainClass" value="com.eg.util.FileWatcher" />

</target>

<target name="jar" depends="init">

<genjar jarfile="JUtar.jar">

<class name="${mainClass}" />

</genjar>

</target>

</project>

Could you please help me to solve this issue..

Thanks in advance.

--Kumaran

_Kumarana at 2007-7-9 21:44:45 > top of Java-index,Java Essentials,Java Programming...
# 3

You need to add a classpath section telling genjar where the roots of your classes may come from

<classpath>

<path refid="classes.classpath"/>

</classpath>

Which assumes the presense some where else of a path definition like

<path id="classes.classpath">

<pathelement location="${jar.home}/ajaryouuse.jar"/>

<pathelement location="${jar.home}/anotherjaryouuse.jar"/>

</path>

dmbdmba at 2007-7-9 21:44:45 > top of Java-index,Java Essentials,Java Programming...
# 4
Thank you very much for your kind reply. I follow the same and till I am frequently getting different kind of errors. Can you please give me an example build.xml file with the implementation of GenJar. That will help me more to solve all my errors.Thanks in advance.--Kumaran
_Kumarana at 2007-7-9 21:44:45 > top of Java-index,Java Essentials,Java Programming...