Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java classpath woes.

Options
  • 16-05-2003 3:59pm
    #1
    Registered Users Posts: 1,722 ✭✭✭


    I'm working on a html parser and I'm using httpunit. I've got my little program compiling fine but when I try and run I get this error thrown up.

    javatrouble.JPG

    Here's my classpath in autoexec.bat.

    SET CLASSPATH=.;C:\jaf-1.0.2\activation.jar;C:\javamail-1.3\mail.jar;C:\j2sdk1.4.1_02\lib;C:\ant\lib;C:\httpunit-1.5.3\jars\Tidy.jar;C:\httpunit-1.5.3\lib\httpunit.jar;%CLASSPATH%

    Any ideas on what I'm doing wrong or what I have to do to get this to work?


Comments

  • Registered Users Posts: 1,931 ✭✭✭Zab


    C:\httpunit-1.5.3\jars\Tidy.jar;C:\httpunit-1.5.3\lib\httpunit.jar

    Are you sure that shouldn't be lib\Tidy.jar? Or jars for httpunit?

    Zab


  • Registered Users Posts: 1,722 ✭✭✭Thorbar


    Tidy.jar is located in the jars folder. Well I've tried it with only putting in C:\httpunit-1.5.3\jars\ in the class path. In the httpunit manual it said to use ant to build the jar files

    By far the easiest way to build HttpUnit is by using ant. If you choose to build with less than the full set of jars, some classes will not compile. The included ant script handles this automatically for you, selecting only those that are appropriate. If you have ant installed, simply go to the main httpunit installation directory and type:

    ant jar
    to build the httpunit jar using any classes available in the jars directory. You can then verify your installation by running one of the examples. The command
    ant run-example
    will compile the examples and run the simplest of them, going to the Meterware web site and following a link to the main HttpUnit site. If all is working properly, it should print out a message telling you the number of links it found there.

    I spent a day trying to get ant to run on my machine and failed.


  • Registered Users Posts: 1,931 ✭✭✭Zab


    Try messing around with the classpath using java -cp instead of putting stuff in the autoexec. ( -cp lets you specify your own classpath instead of using the CLASSPATH environment variable )

    Try it out with just the httpunit specific jars.

    Zab.


  • Registered Users Posts: 1,722 ✭✭✭Thorbar


    ah sounds good thanks zab.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by Thorbar
    I spent a day trying to get ant to run on my machine and failed.

    Wow.

    All you should have to do is extract to a location, set ANT_HOME as an environment variable to the root of where you extracted it, and ideally add the bin directory to your path so you can call ant directly without using a path qualifier.

    The only reason this should fail thereafter is if your JAVA implementation is already screwed, or you don't have JAVA_HOME set as an environment variable.

    Then again, I'm pretty sure thats what you'll say you've done.

    One other thing...if you are packaging your own code into a class, you probably need an entry in the manifest file for the JAR files that you are referencing, as well as having them somewhere on the path. Looking at your pic, though, you're not JARring your own app, so thats not an issue.

    I tend to avoid environment classpaths like the plague. I side with zab on this one : try with java -cp

    jc

    jc


  • Advertisement
  • Closed Accounts Posts: 358 ✭✭CH


    Make sure that either nekoHTML.jar or Tidy.jar is in the classpath

    i dont see a mention of nekoHTML.jar in your classpath?

    just guessing.


  • Registered Users Posts: 1,722 ✭✭✭Thorbar


    CH you can set it to tidy or to nekoHTML, one parser is stricter then the other.

    Lads is there anyway to get java to display what classpath its using?


  • Registered Users Posts: 1,722 ✭✭✭Thorbar


    Thanks bonkey I was putting ant in the wrong path variable.


  • Registered Users Posts: 2,010 ✭✭✭Dr_Teeth


    I rarely if ever rely on the windows system paths for classpath stuff. Use -cp or make a batch file (or better yet a shell script if you have cygwin installed) to run your java applications..

    Teeth.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    When I used HTTPUnit I used NekoHTML and didn't have any problems with it. The only problem I had was with RHINO (js.jar).

    There is also HTMLUnit, which is similar. It's been a while when I looked at both but I remember one of the two was a serious pain to set up and the other one wouldn't work with sessions. So I gave up on both of them and used RobotJ instead (which isn't free).


  • Advertisement
Advertisement