Re: [Httpunit-develop] Minimal javac java Example (stand-alone) / classpath hell
Brought to you by:
russgold
From: Izzy A. <izz...@gm...> - 2011-03-25 01:38:12
|
> Why did it NOT throw an exception at WebConversation? WebRequest is > later in the Example.java source file. Surely it found the classes? No, the order in the source doe isn't necessarily the order the JVM uses to resolve classes. The httpunit.jar file doesn't include all the required dependencies. You need some more jars in your classpath (from ~/Downloads/httunit-1.7/jars) For that particular example, at a minimum you need: java -classpath ../Downloads/httpunit-1.7/jars/js-1.6R5.jar:../Downloads/httpunit-1.7/jars/nekohtml-0.9.5.jar:../Downloads/httpunit-1.7/jars/xercesImpl-2.6.1.jar:../Downloads/httpunit-1.7/lib/httpunit.jar:. Example But for convenience, If I were doing that on the command line, I'd (personally, probably) do something like: export MY_JARS=`find ~/Downloads/httpunit-1.7 -name "*.jar" | tr '\n' ':'` java -classpath $MY_JARS:. Example On Thu, Mar 24, 2011 at 6:31 PM, Dee Ayy <de...@gm...> wrote: > I am under the impression that httpunit can run stand-alone. What > minimal steps do I need to take to build and run Example.java from my > own path, so that I know I'm not corrupting the httpunit project > files? > > This is what I've done, but am getting java.lang.NoClassDefFoundError > > 1) Download http://prdownloads.sourceforge.net/httpunit/httpunit-1.7.zip?download > (link on http://httpunit.sourceforge.net/ page "Download 1.7") > 2) Expand httpunit-1.7.zip into its own folder ~/Downloads/httpunit-1.7 > 3) Open shell and cd to ~/Downloads/httpunit-1.7 > 4) Run ant jar > 5) Run ant run-example > Assumed httpunit is good to go. Let's start custom "Hello World" > 6) Copy httpunit-1.7/examples/Example.java to ~/custom/Example.java > 7) cd ~/custom > 8) javac -version > javac 1.6.0_24 > 9) javac -classpath ~/Downloads/httpunit-1.7/lib/httpunit.jar Example.java > 10) ls > Example.class Example.java > 11) java -version > java version "1.6.0_24" > Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326) > Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode) > 12) java -classpath . Example > Exception in thread "main" java.lang.NoClassDefFoundError: > com/meterware/httpunit/WebRequest > Caused by: java.lang.ClassNotFoundException: com.meterware.httpunit.WebRequest > ... > Why did it NOT throw an exception at WebConversation? WebRequest is > later in the Example.java source file. Surely it found the classes? > > 13) java -classpath .:~/Downloads/httpunit-1.7/lib/httpunit.jar Example > Exception in thread "main" java.lang.NoClassDefFoundError: > com/meterware/httpunit/WebRequest > Caused by: java.lang.ClassNotFoundException: com.meterware.httpunit.WebRequest > > 14) java -classpath .:~/Downloads/httpunit-1.7/build/classes/ Example > Exception in thread "main" java.lang.NoClassDefFoundError: > com/meterware/httpunit/WebRequest > Caused by: java.lang.ClassNotFoundException: com.meterware.httpunit.WebRequest > > 15) java -classpath > .:~/Downloads/httpunit-1.7/lib/httpunit.jar:~/Downloads/httpunit-1.7/build/classes/ > Example > Exception in thread "main" java.lang.NoClassDefFoundError: > com/meterware/httpunit/WebRequest > Caused by: java.lang.ClassNotFoundException: com.meterware.httpunit.WebRequest > > What steps am I missing? Please keep it minimal. No Tomcat; No more > ant, etc. Can we just use javac and java now that ant run-example > worked? > > I've been trying to avoid using an IDE because I will ultimately run > this on a low power machine. But maybe I can put everything in 1 jar > using Eclipse and eventually do "java -jar Custom.jar" on the low > power machine. Unless I am really close above. > > Thanks. > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Httpunit-develop mailing list > Htt...@li... > https://lists.sourceforge.net/lists/listinfo/httpunit-develop > |