Originally Posted by
punkdanne
But i have never used classpaths before, and am not quite sure what they are reffering to. isn't it enough just to leave these jars in the same folder as the project?
For simple projects, yes.
But if you cannot execute your main .class file with java, then you will need to use the -cp parameter to specify the location of your class files.
For example, let's say you have your project's main class (let's call it MyProject.class) at /home/you/project directory, and there is a class you want to use located at /home/anotherdude/classes
In that case, you will need to run MyProject.class using this command:
Code:
java -cp /home/you/project:/home/anotherdude/classes MyProject
What that command does is tell the java virtual machine to look for classes to run at /home/you/project and /home/anotherdude/classes directories. Notice that : symbol is used to separate the different directory paths.
If you are running the java command from the same directory that your class file is, then you can use ./ instead of the full directory name.
Bookmarks