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
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:

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


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

try {
tidy.setErrout(new PrintWriter(new
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);




Thufir Hawat
Sign-up for Ads Free at Mail.com
Received on Wednesday, 19 January 2005 00:55:51 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:38:55 UTC