Jar retrieval
Question:
I have a small question about turning in the labs- my lab
uses a couple of other classes contained in a jar file. I put my project
and this jar file
together in a zip file and put it on the website for downloading. To test
it and see if I can run the project, I removed the needed jar file from my
computer. Now, the only way I can get it to work is to include the needed
jar file in my classpath and then reboot for the changes to take effect.
It also worked if I have a generic jar file name in the classpath and
change the name of my jar file to match. This seems kinda cumbersome- am
I doing something wrong?
Answer
Great question and testing to see if your stuff works on another machine.
For someone else to get the code in the jar file to work, they
would need to do one of a couple possibilities (some you mentioned):
-
include the needed jar file in my classpath and then reboot for
the changes to take effect.
yes, that works, and as you mention, it is kinda cumbersome
- a generic jar file name in the classpath and change the name of
the jar to match.
nice idea if one remembers they did this
- once downloaded, unjar the needed jar file
this is what I usually do. I use the jar for easy downloading and
then put it in a tmp directory, unjar it and then run it.
Once it works, I remove everything and do the same to the next
person's code. This way I do not have to change the CLASSPATH each
time or remember anything
Notice for the last option, that for some submissions you will have
jars within the downloaded jar. Specifically, if you have a Bean,
you would want to have that .jar with the manifest, etc all packaged
nicely and included in the .jar (.zip) that would be downloaded. For
client/server code, you would probably have a jar for the client
stuff, a jar for the server stuff and then put both jars in a downloadable
jar