ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Abley <james.ab...@volantis.com>
Subject Re: including libs in my project
Date Thu, 20 Jan 2005 12:30:32 GMT
On Thu, 2005-01-20 at 11:34, seppe@pandora.be wrote:
> Hi,
> 
> I created a project, and I decided to give ANT a try to create a JAR file.
> The structure of my project is like this:
> 
> src
>   - lib  => contains all libraries (jar files) I use, mainly Axis jar's
>   - be   => contains classes to call a webservice I use
>   - controller  =>  contains my listeners
>   - view  => contains my SWING frames
>   - main  => has only one Class "Demo" which has my main method to start my app
>   - net  =>  another package with classes I use to call some webservice
> bin
>   => I want that ANT compiles my java files to class files and store those class files
here
> 
> 
> So the main things you should know is that I store libs I use in "src/lib" and that my
main class is located in "main/Demo".
> 
> I have the following build.xml file:
> 
> <?xml version="1.0"?>
> <project name="ChatTranslator" default="deploy" basedir=".">
> 
>     <property name="sourcedir" value="${basedir}/src"/>
>     <property name="targetdir" value="${basedir}/bin"/>
>     <property name="librarydir" value="${basedir}/src/lib"/>
> 
>     <target name="compile">
>       <javac srcdir="${sourcedir}"
>              destdir="${targetdir}"
>              debug="on"
>       >   
>           <classpath>
>           	  <pathelement location="${targetdir}"/>
>               <fileset dir="${librarydir}">
>                   <include name="*.jar"/>
>               </fileset>
>           </classpath>        
>       </javac>
>     </target>
>     
> 
> 	<target name="deploy" depends="compile">
> 		<jar destfile="${basedir}/ChatTranslator.jar" basedir="${targetdir}" compress="true">

> 		       <fileset dir="${sourcedir}">
>                   <include name="lib/*.jar"/>
>               </fileset>	
> 			<manifest>			
> 				<attribute name="Main-Class" value="main.Demo" />
> 			</manifest>
> 		</jar>
> 	</target>
> </project>
> 
> 
> 
> my jar file is created and contains all my directories with compiled class files. My
lib folder is there as well, but it looks like it doesn't work. I get this when I do "java
-jar ChatTranslator.jar" in a command window:
> 

Does the lib folder have any jar's in it?

> Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
> 
> So it looks like it still can't find my libs :-(
> 
> Can anyone help me? Or correct my build.xml file? I'm struggling with this for almost
more than 3 hours, and it's getting on my nerves.
> 
> 

Try setting the Class-Path attribute in the manifest as well. You may
need to use pathconvert on a classpath fileset to map the paths from
absolute to relative; i.e. /home/me/src/lib/some.jar to lib/some.jar.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message