I administer a linux box with many java
users. I noticed that many users downloaded several jakarta projects or other open source projects and included the relevant jars in their own directories, and manually edited their CLASSPATH each time they added a jar. I decided to make a central repository (/usr/local/jars) for all the jars, and make a csh script to automatically set the classpath as well as some other variables. I figured I would share it in case anyone else wants to use it, translate it to bash, or offer suggestions.
I have put this in /etc/javasetup.csh:
And now all I have to do to add more jars is to either move it into /usr/local/jars or make a symbolic link from /usr/local/jars to the package. All users can include the line "source /etc/javasetup.csh" in their .cshrc file. It also allows me to update the jdk and merely change one line in the javasetup.csh to allow all users to use the updated jdk.
I have tried making a sh/bash script too, though my knowledge of bash is limited.
Please feel free to use/modify/point out any bugs or platforms where these don't work. Or offer suggestions on what you have done differently.