Question

I am trying to figure out how I may be able to setup my classpath file for java so that it could accept a jar and launch a class file not in the same directory as the one the user is currently in.

My code below shows java -cp .:jsoup-1.7.3.jar Class1 will allow me to launch the Class1 file without any problems if I am in the same directory as the Class1 file which also contains the jsoup file. However I am trying to launch it as if I were in another directory so I would try something like

java -cp .:jsoup-1.7.3.jar /pathtofile/Class1

However this doesn't work because you need to set the classpath correctly. How would I do this so I could do something like

java -cp {correct absolute class paths and arguments to include jsoup jar} Class1 

Thank you in advanced.

Was it helpful?

Solution

"." means the current directory in Linux. so you'll need to substitute (or add) the path to where your .class file is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top