Re: [Htmlparser-user] ParserException error (newbie question)
Brought to you by:
derrickoswald
From: Andreas K. <lin...@gm...> - 2011-01-19 13:41:41
|
Sorry, that was a typo from my side. I've also tried without the extension as you suggest, i.e. $ java -classpath /usr/share/java/libhtmlparser.jar test_htmlparser but this result in the error message below? Exception in thread "main" java.lang.NoClassDefFoundError: test_htmlparser Caused by: java.lang.ClassNotFoundException: test_htmlparser 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. Program will exit. Thanks for your quick response by the way. /Andreas Den 19-01-2011 13:55, Derrick Oswald skrev: > Sorry, I didn't read closely enough. > When you issue the java command it needs no extension. > > $ java -classpath /usr/share/java/ libhtmlparser.jar test_htmlparser > > On Jan 19, 2011 10:42 AM, "Andreas Kring" <lin...@gm... > <mailto:lin...@gm...>> wrote: > > 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" <lin...@gm... > <mailto:lin...@gm...> > >> <mailto:lin...@gm... <mailto:lin...@gm...>>> > 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 > >> > Htm...@li... > <mailto:Htm...@li...> > >> <mailto:Htm...@li... > <mailto:Htm...@li...>> > >> > 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 > >> Htm...@li... > <mailto:Htm...@li...> > >> 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 > > Htm...@li... > <mailto:Htm...@li...> > > 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 > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user |