You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "seppe@pandora.be" <se...@telenet.be> on 2005/01/20 12:34:47 UTC

including libs in my project

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:

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.


Thanks a lot in advance!

Seppe



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


Re: including libs in my project

Posted by James Abley <ja...@volantis.com>.
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


RE: including libs in my project

Posted by Stephen McConnell <mc...@dpml.net>.

> -----Original Message-----
> From: seppe@pandora.be [mailto:seppe@telenet.be]
> Sent: Thursday, 20 January 2005 10:05 PM
> To: user@ant.apache.org
> Subject: including libs in my project
> 
> 


> Exception in thread "main" java.lang.NoClassDefFoundError: 
> javax/xml/rpc/ServiceException
<
> So it looks like it still can't find my libs :-(

Are the ServiceException class or any classes that ServiceException is 
dependent contained in the jar as classes or as nested jar files?  If 
they are nested then they wil not be found because the standard 
classloader does not support nested jar file loading.

Steve.



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