Re: Java CLASSPATH question
sam.n.seab...@gmail.com wrote:
The commons-codec-1.3.jar file _is_ in the directory specified in the
classpath.
Alex.From.Ohio.Java@gmail.com wrote:
Classpath should have directories with *.class files or jar [sic] files
itself.
Which is exactly what the OP did.
$ java -classpath ~/src:~/src/commons-codec-1.3.jar Xpacket
And you mention it, Alex, because ... ?
jar file is included to classpath only if it is in special directory
$JAVA_HOME/jre/lib/ext
That is completely false.
All jar files from this "magic" directory are included to the
classpath.
The extension directories, comprising $JAVA_HOME/jre/lib/ext/ by default, are
intended to expand one's Java platform itself. They are not really for
application libraries.
<http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html#extclass>
The OP did the correct thing by using the classpath option to the Java command.
Otherwise they (jar files) should be mentioned literally.
Which is exactly what the OP did. However, it is not the only way to include
JAR files. One could use the wildcard notation:
java -cp $LIBRARY_ROOT/* etc.
It's bad practice to put .class and .jar files in one's source directory, BTW.
However, none of this addresses the OP's actual problem, which was not due to
the use of the classpath option as far as I can see from here.
It would help, OP, if you posted a complete example, say one which declares
'outbytes' [sic: should be camel case]. I can't see anything wrong with what
you've posted so far, although you definitely should put Xpacket in a named
package. That might even help. Also, change your import to a single-type
import, not import-on-demand. Post a complete example with those changes, and
run it to see if it helps. I happen to have the same version of the codec
JAR, so I'd try a complete example.
--
Lew