Search code examples
javapythonjythonhtmlunit

Running HtmlUnit with Jython - issue with startup on command line


I tried to run HtmlUnit with Jython following this tutorial:

http://blog.databigbang.com/web-scraping-ajax-and-javascript-sites/

but it does not work for me. I am unable to import the com.gargoylesoftvare packages, there are only some HTML files in HtmlUnit folder, which I need to import somehow?

The tutorial says to run python script like this:

/opt/jython/jython -J-classpath "htmlunit-2.8/lib/*" gartner.py

and I try to run:

java -jar /Users/adam/jython/jython.jar -J-classpath "htmlunit-2.8/lib/*" gartner.py

My problem is I am getting an "Unknown option: J-classpath". But there is not even word about -J-classpath parameter on Jython.org. I would be VERY glad for any advice. I am running jython standalone v. 2.5.2 on Snow Leopard


Solution

  • Your entire command line is being processed by the java command (as it should), and -J-classpath is indeed not a valid command line option for java. You should really try to follow the exact steps of the tutorial, because you are missing several important steps (and kind of making up your own steps).