Re: ParserException error (newbie question)

Andreas Kring <[email protected]>
Newsgroups gmane.comp.parsers.htmlparser.user
Message-ID <[email protected]>
Thanks for your answer. It doesn't seem to work. I have tried both

$ java -classpath /usr/share/java/libhtmlparser.jar test_htmlparser.java

and

$ java -classpath .:/usr/share/java/libhtmlparser.jar test_htmlparser.java

Both of the commands result in the error message:

Exception in thread "main" java.lang.NoClassDefFoundError: 
test_htmlparser/java
Caused by: java.lang.ClassNotFoundException: test_htmlparser.java
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: test_htmlparser.java. Program will exit.

I have also tried to

$ export CLASSPATH=/usr/share/java/libhtmlparser.jar

and the compile and run the program with

$ javac test_htmlparser.java (which gives no errors)
$ java test_htmlparser

but I get the same error message as above...

Is there something else I can try?

Kind regards
Andreas


Den 19-01-2011 07:55, Derrick Oswald skrev:
> Don't you need the classpath when you run it too?
>
> On Jan 18, 2011 11:46 PM, "Andreas Kring" <[email protected]
> <mailto:[email protected]>> wrote:
>  > Hello all.
>  >
>  > I have a newbie question that I hope you can help me with:
>  > I'm using Ubuntu 10.04 and I have just installed the package
>  > libhtmlparser-java. I get no errors when compiling the code below
>  > (test_htmlparser.java) using the command
>  >
>  > $ javac -classpath /usr/share/java/libhtmlparser.jar test_htmlparser.java
>  >
>  > but when I try to run the program, I get the following error:
>  >
>  > $ java test_htmlparser
>  > Exception in thread "main" java.lang.NoClassDefFoundError:
>  > org/htmlparser/util/ParserException
>  > at test_htmlparser.main(test_htmlparser.java:12)
>  > Caused by: java.lang.ClassNotFoundException:
>  > org.htmlparser.util.ParserException
>  > at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
>  > at java.security.AccessController.doPrivileged(Native Method)
>  > at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
>  > at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
>  > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
>  > at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>  > ... 1 more
>  >
>  >
>  >
>  > What can I do to fix this?
>  >
>  > /Andreas
>  >
>  >
>  > ----- test_htmlparser.java begin -----
>  >
>  > import org.htmlparser.*;
>  > import org.htmlparser.util.*;
>  >
>  > class test_htmlparser
>  > {
>  > public static void main(String[] args)
>  > {
>  > try {
>  > Parser parser = new Parser("http://www.sslug.dk");
>  > } catch (ParserException e) {
>  > System.err.println("Caught ParserException: " + e.getMessage());
>  > }
>  >
>  > }
>  > }
>  >
>  > ----- test_htmlparser.java end -----
>  >
>  >
> ------------------------------------------------------------------------------
>  > Protect Your Site and Customers from Malware Attacks
>  > Learn about various malware tactics and how to avoid them. Understand
>  > malware threats, the impact they can have on your business, and how you
>  > can protect your company and customers by using code signing.
>  > http://p.sf.net/sfu/oracle-sfdevnl
>  > _______________________________________________
>  > Htmlparser-user mailing list
>  > [email protected]
> <mailto:[email protected]>
>  > https://lists.sourceforge.net/lists/listinfo/htmlparser-user
>
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
>
>
>
> _______________________________________________
> Htmlparser-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/htmlparser-user


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.