>I realize that there is not one answer to this question but I would like
>some of you veteran java/linux developers to suggest what the optimal
>directory structure and setup of the CLASSPATH variable is.
>
>I am, frankly, a C++ programmer trying to learn java and I am
>continually frustrated over the myriad ways I can be foobared by
>CLASSPATH. And then packages on top of that.
>
I personally use a little shell script which I name 'd' (for develop), and
that looks like:
# script for setting up development environment
# changes for using postgresql
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
PGDATA=/usr/local/pgsql/data
PGLIB=/usr/local/pgsql/lib
POSTGRES_HOME=/usr/local/pgsql
# don't forget to add hosts to /usr/local/pgsql/data/pg_hba.conf
export MANPATH PGDATA PGLIB POSTGRES_HOME
# changes for using java
PATH=.:$PATH:/usr/local/jdk1.1.6/bin
CLASSPATH=.:/usr/local/jdk1.1.6/lib/classes.zip
# changes for using the JDBC driver of postgresql
# add the directory where postgresql.jar resides
CLASSPATH=$CLASSPATH:/usr/local/pgsql/lib/postgresql.jar
#changes for using the swing release
CLASSPATH=$CLASSPATH:/usr/local/swing-1.0.3/swingall.jar
#CLASSPATH=$CLASSPATH:/usr/local/swing-1.1beta/swingall.jar
#changes for JavaPureCheck
CLASSPATH=$CLASSPATH:/usr/local/jpc/javapurecheck.jar
# for project
CLASSPATH=$CLASSPATH:/usr/src/project
cd /usr/src/project
export PATH CLASSPATH
Some explanation:
1. You must invoke this script on your command line (in an x-terminal)
. d
(dot, followed by space, followed by d) to execute the script in the current
shell (else the settings in this script are only valid for a new shell that
immediately ends).
2. Replace /usr/src/project with your source directory for your application.
3. You could put the content of this script also in your .bash_profile but I
find it cleaner to use a separate script that I can modify and re-execute
using . d
4. The section changes for using java points adds to the classpath the
classes.zip of your favourite JDK.
5. The section labeled "changes for using swing" is there because I use
swing as my GUI class library. Notice that by simply commenting in and out
you can switch between swing-1.0.3 and swing-1.1beta2
6. The section labeled "changes for using JDBC driver" is there because I am
making an entreprise Java application using the postgresql database engine.
7. The section labeled "changes for using JavaPureCheck" is there because I
regularly check if my code is 100% pure java.
8. Make shure that the 'd' script is in a directory where your PATH can find
it. Personally I add to my .bash_profile a directory called /usr/src/develop
where I put my d script.
Hope this helps, regards
Wim Ceulemans