Search code examples
javaubuntuclasspathubuntu-10.10

Adding Java Classes


Noob Question I know but can you explain to me how I can install access downloaded java classes.

I am trying to use HtmlUnit.. I downloaded the archive.. inside there are two folders "lib" and "apidocs".

I have tried various combinations of editing /etc/environment and .bashrc but I still can't "import com.gargoylesoftware.htmlunit"

I am using Ubuntu 10.10

Thanks in advance


Solution

  • A Java process is launched like so:

    java -classpath lib/one.jar:lib/two.jar:my_classes com.example.Main

    Here, my_classes is a directory containing some compiled class files, one.jar and two.jar are archive files containing compiled class files, and com.example.Main is the name of a class containing a static main(String[]) method.

    That's the low-level view. In practice, most people use tools to help them manage the classpath and launch the program. Are you using any such tools (Ant, Maven, an IDE like Eclipse or NetBeans, shell scripts?)