|
Classpath and Java
Setting your classpath is really only important when you want to start using methods that other people have created before you. Usually they come as .jar files. I keep all my jars in one place to make them easier to find.
For example all my jars are in /home/jeffro/java/jars (or say c:/jars, on a windows machine) Then when ever I add a jar to the jars directory I just add it to my classpath like so:
classpath=/home/jeffro/java/jars/other.jar:/home/jeffro/java/jars/cool.jar
[or if you want to get all snazzy]
classpath="/home/jeffro/java/jars/other.jar"
classpath="$classpath:/home/jeffro/java/cool.jar"
etc...
Then I can use all the methods that are in that jar like they were part of my own code. (note, on a windows machine, you would seperate the paths to your jars with a semicolon rather than a colon)
If you open up a jar (you can use most any archive program, TAR or WinRar would do the trick). You can see the directory structure you would indicate in your import statement. For example in my cool.jar there is a method called stringUtils that I want to use so would just put:
import path.to.stringUtils;
Then I can access all of the methods in stringUtils. The path.to is indicated by the directory structure in the jar so the actual path to stringUtils would be (from when you first open the jar) /path/to/stringUtils.class
It sounds like alot of work but when you start writing really big programs its nice to be able to use a methods other people have written to save time.
jeffro
__________________
Jeffro
Linux counter#:213782
GnuPG ID: 406238E7
|