W3C home > Mailing lists > Public > html-tidy@w3.org > January to March 2005

JTidy sample code gives Exception in thread "main"

From: THUFIR HAWAT <thufir.hawat@mail.com>
Date: Wed, 19 Jan 2005 00:55:16 +0000
To: html-tidy@w3.org
Message-Id: <20050119005516.709097900A3@cal1-1.us4.outblaze.com>

I slightly modified
<http://sourceforge.net/docman/display_doc.php?docid=1298&group_id=13153>.
This is just a sample JTidy class which parses a url. Rather than
have the url entered by the user I hard coded the url, also I changed
the name.

It's such a common error the google results are massive...
I don't understand the error message :(

////////////command line//////////////////

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>javac @comp

C:\>java -classpath C:\java\sources\ atreides.jtidy.TidyTest
Exception in thread "main" java.lang.NoClassDefFoundError:
atreides/jtidy/TidyTest

C:\>type comp
-d C:\java\classes\
-g
-sourcepath C:\java\sources\
-classpath .;C:\java\classes\;C:\java\classes\org\w3c\tidy\Tidy.jar

C:\java\sources\atreides\jtidy\TidyTest.java

C:\>type C:\java\sources\atreides\jtidy\TidyTest.java
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;

}

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);
}

catch ( IOException e ) {
System.out.println( this.toString() + e.toString() );

}
}

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();
   }

}

C:\>
C:\>

Thanks,

Thufir Hawat
-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
Received on Wednesday, 19 January 2005 00:55:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:55 GMT