Tuesday, October 28, 2008

How do I set my java classpath?

How do I set my java classpath?

Problem

Linux uses Red Hats java package instead of the Sun jdk.

Reason

The java interpreter from the standard Red Hat installation is placed in /usr/bin, which is in the path where Linux search for executables. This will be used be default if you don't specify otherwise.

To find the java classes, you also have to set the java classpath to point to the java kit you want to use.

Solution

Set your PATH and CLASSPATH environment variables to reflect which java kit you want to use.

In the ITU Linux machines in 2003, the following java kits are installed: jdk1.3.1 and j2sdk1.4.1. They are placed in /usr/java.

To use jdk1.3.1, add the following lines to the file ".bashrc" in your home directory:

export PATH=/usr/java/jdk1.3.1/bin:$PATH
export JAVA_HOME="/usr/java/jdk1.3.1"
export CLASSPATH=.:/usr/java/jdk1.3.1

If you want to use the j2sdk1.4.1, replace jdk1.3.1 with j2sdk1.4.1 and it should work.

netstat

Examples

netstat

Displays generic net statistics of the host you are currently connected to.

netstat -an

Shows all connections to the server including the source and destination ips and ports if you have proper permissions.

netstat -rn

Displays routing table for all ips bound to the server.

netstat -an |grep :80 |wc -l

Display the amount of active connections on port 80. Removing the pipe and wc command would display each connection.

netstat -natp

Display active Internet connections. See document CH001079 for an example of output.