ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: error: ...class definition existed..can no longer be found ?
Date Thu, 03 Feb 2005 10:30:42 GMT
No. The JAR-spec [1] sais:
  Main-Class : 
  The value of this attribute defines the relative path of the main
application class which the launcher 
  will load at startup time. The value must not have the .class extension
appended to the class name.

  Class-Path : 
  The value of this attribute specifies the relative URLs of the extensions
or libraries that this 
  application or extension needs. URLs are separated by one or more spaces.
The application or extension 
  class loader uses the value of this attribute to construct its internal
search path. 

Means:
  "java -jar TidyTest.jar" adds TidyTest.jar to the classpath and looks into
TidyTest´s manifest for
  a Main-Class attribute. If specified that class will be started.
  Like
    java -cp TidyTest.jar atreides.jtidy.TidyTest 

  But you need the Tidy.jar also, therefor you would start
    java -cp TidyTest.jar;Tidy.jar atreides.jtidy.TidyTest 
  So you have to specify the Class-Path.
    <target name="manifest" depends="compile">
        <manifest file="${destdir}/MANIFEST.MF">
            <attribute name="Main-Class"
value="atreides.monsters.${mainClass}" />
            <attribute name="Class-Path" value="Tidy.jar" />
        </manifest>
    </target>

With that manifest Java searches for Tidy.jar in the directory of
TidyTest.jar.


Jan 



[1] http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html
[2] http://ant.apache.org/manual/CoreTasks/jar.html



> -----Ursprüngliche Nachricht-----
> Von: THUFIR HAWAT [mailto:thufir.hawat@mail.com]
> Gesendet am: Donnerstag, 3. Februar 2005 11:19
> An: user@ant.apache.org
> Betreff: AW: error: ...class definition existed..can no 
> longer be found
> ?
> 
> Thank you, Jan,
> 
> here's my manifest, extracted from the jar:
> 
> Manifest-Version: 1.0
> Ant-Version: Apache Ant 1.6.2
> Created-By: 1.5.0_01-b08 (Sun Microsystems Inc.)
> Main-Class: atreides.monsters.TidyTest
> 
> shouldn't the Main-Class value do the trick, so that I don't 
> need to include the classpath switch when running the .jar?
> 
> 
> Thanks,
> 
> Thufir
> 
> 
> 
> ///////////Jan wrote:
> Your buildfile is correct, but your call for start is not.
> While compiling you have included Tidy.jar (${includeJar}), 
> but you havent
> when starting TidyTest.jar.
> 
> 1) add the classpath when starting via "java -jar" or
> 2) support a classpath entry for the manifest file of TidyTest.jar
> 
> 
> Jan
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: THUFIR HAWAT [mailto:thufir.hawat@mail.com]
> > Gesendet am: Donnerstag, 3. Februar 2005 09:44
> > An: user@ant.apache.org
> > Betreff: error: ...class definition existed..can no longer 
> be found ?
> > 
> > Is the source of this error due to build.xml?
> > 
> > 
> > 
> > ////////////build.xml////////////////
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <project name="jtidy test" default="package">
> > 
> > 	<property name="destdir"
> > 	value="C:\java\classes\" />
> > 	<property name="sourcedir"
> > 	value="C:\java\sources\atreides\jtidy\" />
> > 	<property name="includeJar"
> > 	value="C:\java\sources\org\w3c\tidy\Tidy.jar" />
> > 	<property name="mainClass"
> > 	value="TidyTest" />
> > 
> > 	<target name="clean">
> > 		<delete dir="${destdir}" />
> > 	</target>
> > 
> > 	<target name="prepare" depends="clean">
> > 		<mkdir dir="${destdir}" />
> > 	</target>
> > 
> > 	<target name="compile" depends="prepare">
> > 		<javac
> > 			srcdir="${sourcedir}"
> > 			destdir="${destdir}"
> > 			classpath="${includeJar}"
> > 		/>
> > 	</target>
> > 
> > 
> > 
> > 
> > 	<target name="manifest" depends="compile">
> > 		<manifest file="${destdir}/MANIFEST.MF">
> > 			<attribute name="Main-Class" 
> > 			value="atreides.monsters.${mainClass}" />
> > 		</manifest>
> > 	</target>
> > 
> > 	<target name="package" depends="manifest">
> > 		<jar jarfile="${destdir}/${mainClass}.jar"
> > 		basedir="${destdir}"
> > 		manifest="${destdir}/MANIFEST.MF" />
> > 	</target>
> > 
> > </project>
> > 
> > 
> > 
> > 
> > ////////////dos///////////////////
> > Microsoft Windows 2000 [Version 5.00.2195]
> > (C) Copyright 1985-2000 Microsoft Corp.
> > 
> > C:\Documents and Settings\Administrator>cd ..
> > 
> > C:\Documents and Settings>cd ..
> > 
> > C:\>set CLASSPATH=
> > 
> > C:\>ant
> > Buildfile: build.xml
> > 
> > clean:
> > [delete] Deleting directory C:\java\classes
> > 
> > prepare:
> > [mkdir] Created dir: C:\java\classes
> > 
> > compile:
> > [javac] Compiling 1 source file to C:\java\classes
> > 
> > manifest:
> > 
> > package:
> > [jar] Building jar: C:\java\classes\TidyTest.jar
> > 
> > BUILD SUCCESSFUL
> > Total time: 8 seconds
> > C:\>java -jar java\classes\TidyTest.jar
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > atreides/monsters/T
> > idyTest
> > 
> > C:\>
> > 
> > 
> > ///////////////////source/////////////
> > // adapted from source available at:
> > // 
> > <http://sourceforge.net/docman/display_doc.php?docid=1298&grou
> > p_id=13153>
> > 
> > 
> > package atreides.jtidy;
> > 
> > import java.io.IOException;
> > import java.net.URL;
> > import java.io.BufferedInputStream;
> > import java.io.FileOutputStream;
> > import java.io.PrintWriter;
> > import java.io.FileWriter;
> > import org.w3c.tidy.Tidy;
> > 
> > 
> > 
> > public class TidyTest implements Runnable {
> > 
> >     private String url;
> >     private String outFileName;
> >     private String errOutFileName;
> >     private boolean xmlOut;
> > 
> >     public TidyTest(String url, String outFileName, String 
> > errOutFileName, boolean xmlOut) {
> >         this.url = url;
> >         this.outFileName = outFileName;
> >         this.errOutFileName = errOutFileName;
> >         this.xmlOut = xmlOut;
> >     }//tidyTest
> > 
> >     public void run() {
> >         URL u;
> >         BufferedInputStream in;
> >         FileOutputStream out;
> >         Tidy tidy = new Tidy();
> > 
> >         tidy.setXmlOut(xmlOut);
> >         try {
> >             tidy.setErrout(new PrintWriter(new 
> > FileWriter(errOutFileName), true));
> >             u = new URL(url);
> >             in = new BufferedInputStream(u.openStream());
> >             out = new FileOutputStream(outFileName);
> >             tidy.parse(in, out);
> >         }//try
> >         catch ( IOException e ) {
> >             System.out.println( this.toString() + e.toString() );
> >         }//catch
> >     }//run
> > 
> >     public static void main( String[] args ) {
> > 
> > 	String url = "http://www.google.com/";
> > 	String output = "output.txt";
> > 	String errorLog = "errorLog.txt";
> > 
> > //	TidyTest t1 = new TidyTest(url,output,errorLog,true);
> > //	Thread th1 = new Thread(t1);
> > //	th1.start();
> >     }//main
> > }//TidyTest
> > 
> > 
> > 
> > Thank you,
> > 
> > Thufir Hawat
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message