how to etup linux classpath?

J

JAVA Rookie

Hi, all:
I am new in linux world,
so, how can I setup java classpath in linux?

i use:
setenv JAVA_HOME /usr/java
setenv CLASSPATH .;/usr/java/j2sdk1.4.2_02

under one user account (droup: root), but failed.
should I doing this under root?
and how can I write this to system environment setting? like windows XP.
Thanks in advance.
 
S

Sudsy

JAVA said:
Hi, all:
I am new in linux world,
so, how can I setup java classpath in linux?

i use:
setenv JAVA_HOME /usr/java
setenv CLASSPATH .;/usr/java/j2sdk1.4.2_02

under one user account (droup: root), but failed.
should I doing this under root?
and how can I write this to system environment setting? like windows XP.
Thanks in advance.

Those look like c-shell commands. Not all users run the c-shell.
I prefer the Korn or Bourne shell. For users like myself the
commands would be as follows:

JAVA_HOME=/usr/java
CLASSPATH=.:/usr/java/j2sdk1.4.2_02
export JAVA_HOME CLASSPATH

(Note that the separator in *nix is the colon, not the semi-colon.)

You can always find the name of your current shell by typing:

ps -f

Out of the two lines which should be displayed (not including
the header), your shell is likely the top one. Here's what the
output looks like on my system:

UID PID PPID C STIME TTY TIME CMD
sudsy 1058 1046 0 Dec07 pts/0 00:00:00 ksh
sudsy 7008 1058 0 18:43 pts/0 00:00:00 ps -f
 
D

David Postill

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

<snip />

| You can always find the name of your current shell by typing:
|
| ps -f
|
| Out of the two lines which should be displayed (not including
| the header), your shell is likely the top one. Here's what the
| output looks like on my system:
|
| UID PID PPID C STIME TTY TIME CMD
| sudsy 1058 1046 0 Dec07 pts/0 00:00:00 ksh
| sudsy 7008 1058 0 18:43 pts/0 00:00:00 ps -f

Hmmm. Mine is the second line, not the top one <grin>:

12> ps -f
UID PID PPID TTY STIME COMMAND
davidp 5568 1 con 02:20:23 /usr/bin/rxvt
davidp 5656 5568 0 02:20:26 /usr/bin/bash
davidp 2072 5656 0 02:28:09 /usr/bin/ps

But then I'm running cygwin (on Windows 2K) and my shell
is running in an rxvt window...

<davidp />

- --
David Postill

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3 - not licensed for commercial use: www.pgp.com
Comment: Get key from pgpkeys.mit.edu:11370

iQA/AwUBP9fXBHxp7q1nhFwUEQJqKQCeNyAbs+x8NpHNieHDzuUKkF27Ej0An3qU
vTSzdyQ0uEXg2EbqNWvvTDy0
=kA7w
-----END PGP SIGNATURE-----
 
S

Sudsy

David Postill wrote:
Hmmm. Mine is the second line, not the top one <grin>:

12> ps -f
UID PID PPID TTY STIME COMMAND
davidp 5568 1 con 02:20:23 /usr/bin/rxvt
davidp 5656 5568 0 02:20:26 /usr/bin/bash
davidp 2072 5656 0 02:28:09 /usr/bin/ps

But then I'm running cygwin (on Windows 2K) and my shell
is running in an rxvt window...

Thanks, David. I just didn't want to get into a discussion about
how to "chain" the PPIDs to the PIDs, especially in a Java
newsgroup. Better to ask that kind of question in a *nix ng. I was
merely trying to address the query as posed. Darn, BASHed again!
 
M

Michael Borgwardt

JAVA said:
Hi, all:
I am new in linux world,
so, how can I setup java classpath in linux?

i use:
setenv JAVA_HOME /usr/java
setenv CLASSPATH .;/usr/java/j2sdk1.4.2_02

under one user account (droup: root), but failed.
should I doing this under root?

You shouldn't do this at all, as it is unnecessary and just creates confusion.
The CLASSPATH environment variable has been obsolete for years, unfortunately
there are still all those old books and webpages around that devote at least
one full chapter to it...

BTW, in linux, environment variables are process-specific, so entering
the above in a shell sets the variables only for that shell as long as its running,
possibly its child processes. To set a variable system-wide, you have to put
it into /etc/profile or a similar place.
 
Joined
Oct 23, 2010
Messages
13
Reaction score
0
How Classpath work in Java ?

Hi,

Its worth noting that if you have two classes with same name in classpath in that case one which comes earlier in classpath will get picked up. this concept is very useful to test patch releases where you update only few classes to quickly test patch release or have added some debug print statement to troubleshoot any issue.

Thanks
Javin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top