[Httpunit-develop] Minimal javac java Example (stand-alone) / classpath hell
Brought to you by:
russgold
From: Dee A. <de...@gm...> - 2011-03-24 22:31:37
|
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. |