using -cp at runtime
Posted on 2002-05-01
I have a .java file thats accessing a .jar file. When I install my software that installs the .java file that calls the .jar file, I will get 'Java Exception Occurred' unless I explicitly go to the CLASSPATH system env variable, and put in the path to the .jar file.
I do not want to do this. I want to be able to install the software and then just run the code with no errors and with the .jar file being found.
I also want this to be able to run on any OS. So this is the problem I need a solution for:
get the current location of the where the .java file is located (since that is the same location that the .jar file will be) and use -cp somehow to specify in the .java file where to find the .jar file without giving an exception. Also, the path of where these files will be will be dynamic. So I'll have to be able to get the path at runtime.