Re: Minimal javac java Example (stand-alone) / classpath hell
Izzy Alanis <[email protected]> Fri, 25 Mar 2011 14:17:00 -0400
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Maven is nice, but it's good to understand the fundamentals too. ;) > Why did the above fail? Yeah, tilde expansion rules are weird. It's important to note that bash (or your shell of choice) is responsible for performing the tilde expansion, the program (java in this case) always sees the fully expanded (non-relative) paths. Tildes at the beginning of an argument are always expanded (caveats may apply). But tildes following colons are only expanded in a "variable assignment" -- an argument with an equal sign in it. As an example: echo FOO=3D.:~/Downloads/httpunit-1.7/lib/httpunit.jar:~/Downloads/httpunit= -1.7/jars/activation-1.1.jar:~/Downloads/httpunit-1.7/jars/js-1.6R5.jar:~/D= ownloads/httpunit-1.7/jars/jtidy-4aug2000r7-dev.jar:~/Downloads/httpunit-1.= 7/jars/junit-3.8.1.jar:~/Downloads/httpunit-1.7/jars/mail-1.4.jar:~/Downloa= ds/httpunit-1.7/jars/nekohtml-0.9.5.jar:~/Downloads/httpunit-1.7/jars/servl= et-api-2.4.jar:~/Downloads/httpunit-1.7/jars/xercesImpl-2.6.1.jar:~/Downloa= ds/httpunit-1.7/jars/xmlParserAPIs-2.6.1.jar vs echo .:~/Downloads/httpunit-1.7/lib/httpunit.jar:~/Downloads/httpunit-1.7/j= ars/activation-1.1.jar:~/Downloads/httpunit-1.7/jars/js-1.6R5.jar:~/Downloa= ds/httpunit-1.7/jars/jtidy-4aug2000r7-dev.jar:~/Downloads/httpunit-1.7/jars= /junit-3.8.1.jar:~/Downloads/httpunit-1.7/jars/mail-1.4.jar:~/Downloads/htt= punit-1.7/jars/nekohtml-0.9.5.jar:~/Downloads/httpunit-1.7/jars/servlet-api= -2.4.jar:~/Downloads/httpunit-1.7/jars/xercesImpl-2.6.1.jar:~/Downloads/htt= punit-1.7/jars/xmlParserAPIs-2.6.1.jar vs echo ~/Downloads/httpunit-1.7/lib/httpunit.jar:~/Downloads/httpunit-1.7/jar= s/activation-1.1.jar:~/Downloads/httpunit-1.7/jars/js-1.6R5.jar:~/Downloads= /httpunit-1.7/jars/jtidy-4aug2000r7-dev.jar:~/Downloads/httpunit-1.7/jars/j= unit-3.8.1.jar:~/Downloads/httpunit-1.7/jars/mail-1.4.jar:~/Downloads/httpu= nit-1.7/jars/nekohtml-0.9.5.jar:~/Downloads/httpunit-1.7/jars/servlet-api-2= .4.jar:~/Downloads/httpunit-1.7/jars/xercesImpl-2.6.1.jar:~/Downloads/httpu= nit-1.7/jars/xmlParserAPIs-2.6.1.jar:. On Fri, Mar 25, 2011 at 11:45 AM, Dee Ayy <[email protected]> wrote: >> For that particular example, at a minimum you need: >> java -classpath >> ../Downloads/httpunit-1.7/jars/js-1.6R5.jar:../Downloads/httpunit-1.7/ja= rs/nekohtml-0.9.5.jar:../Downloads/httpunit-1.7/jars/xercesImpl-2.6.1.jar:.= ./Downloads/httpunit-1.7/lib/httpunit.jar:. >> Example > > I had tried what I thought was the above variation: > java -classpath > .:~/Downloads/httpunit-1.7/lib/httpunit.jar:~/Downloads/httpunit-1.7/jars= /activation-1.1.jar:~/Downloads/httpunit-1.7/jars/js-1.6R5.jar:~/Downloads/= httpunit-1.7/jars/jtidy-4aug2000r7-dev.jar:~/Downloads/httpunit-1.7/jars/ju= nit-3.8.1.jar:~/Downloads/httpunit-1.7/jars/mail-1.4.jar:~/Downloads/httpun= it-1.7/jars/nekohtml-0.9.5.jar:~/Downloads/httpunit-1.7/jars/servlet-api-2.= 4.jar:~/Downloads/httpunit-1.7/jars/xercesImpl-2.6.1.jar:~/Downloads/httpun= it-1.7/jars/xmlParserAPIs-2.6.1.jar > Example > Exception in thread "main" java.lang.NoClassDefFoundError: > com/meterware/httpunit/WebRequest > Caused by: java.lang.ClassNotFoundException: com.meterware.httpunit.WebRe= quest > > Why did the above fail? > I list the current directory "." to find my Example.class > Then I list httpunit.jar then the reamining jars, yet you listed > httpunit.jar last. =A0Does this order matter? > > Your export worked! =A0Thanks. =A0But I'm still confused. > It seems that "-classpath" does not like relative paths? > MY_JARS now contains absolute paths. =A0When I manually type absolute > paths it worked. > > Thanks for saving me from classpath hell. > > Dee > ---------------------------------------------------------------------------= --- 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