LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2002, 03:41 PM   #1
gabadoo
LQ Newbie
 
Registered: Jan 2002
Posts: 8

Rep: Reputation: 0
setting CLASSPATH variable


Hello, i am trying to set the CLASSPATH variable permanently and having no success. I can set it fine in the shell :

root# export CLASSPATH=/usr/java/jdbc/mm.mysql.jdbc-1.2c

then with echo $CLASSPATH i get back

/usr/java/jdbc/mm.mysql.jdbc-1.2c

However i would like to set this variable permanently and I have been searching for information and Im just getting more confused.

I run Redhat linux 7.2

I tried putting it in the /etc/profile file but the echo returns nothing.

If someone could please help me out would be greatly appreciated.

thanks
 
Old 01-21-2002, 03:52 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
if you put it in the /etc/rc.local file then it will work, as long as you export it. you don't need to use the export command just on command line btw.
 
Old 01-21-2002, 04:04 PM   #3
gabadoo
LQ Newbie
 
Registered: Jan 2002
Posts: 8

Original Poster
Rep: Reputation: 0
hmmm

Here are the contents of my /etc/rc.local file:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

CLASSPATH=/usr/java/jdbc/mm.mysql.jdbc-1.2c
export CLASSPATH

When i type echo $CLASSPATH i still get nothing? I wasnt to sure by "as long as you export it?" Did i do it right.

THanks for the help
 
Old 01-21-2002, 04:22 PM   #4
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
i think the rc.local files only set temporary vars for root use during bootup. try setting it in the /etc/profile - or in your user's $HOME/.profile
 
Old 01-21-2002, 05:10 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
rc.local and such like are only exectued on boot, so to have an effect you'd need tou manually run the script, or reboot (or atleast change init level)
 
Old 01-21-2002, 05:15 PM   #6
gabadoo
LQ Newbie
 
Registered: Jan 2002
Posts: 8

Original Poster
Rep: Reputation: 0
i tried rebooting and still nothing. I tried placing the contents in the /etc/profile file, and still nothing. What i dont understand is why other environment variables defined below work, like MAIL, but the CLASSPATH is still giving me trouble. I appreciate the help though

Here are the contents of this file:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc


# Path manipulation
if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/sbin" ; then
PATH=/sbin:$PATH
fi

if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/sbin" ; then
PATH=/usr/sbin:$PATH
fi

if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/local/sbin" ; then
PATH=/usr/local/sbin:$PATH
fi

if ! echo $PATH | /bin/grep -q "/usr/X11R6/bin" ; then
PATH="$PATH:/usr/X11R6/bin"
fi

if ! echo $PATH | /bin/grep -q "/usr/java/jdk1.3.1_02/bin" ; then
PATH="$PATH:/usr/java/jdk1.3.1_02/bin"
fi


# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

CLASSPATH="/usr/java/jdbc/mm.mysql.jdbc-1.2c/mysql_comp.jar"


HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME CLASSPATH HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
if [ -r $i ]; then
. $i
fi
done

unset i
 
Old 01-21-2002, 05:18 PM   #7
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
that's strange... what distro are you using?
 
Old 01-21-2002, 05:24 PM   #8
gabadoo
LQ Newbie
 
Registered: Jan 2002
Posts: 8

Original Poster
Rep: Reputation: 0
hehe

Seems like after a reboot, it now works! Anyhow thanks for your help, must be frustrating helping out the newbies
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the CLASSPATH environment variable Rodotheos Programming 3 06-20-2005 05:30 AM
Setting up my java classpath in redhat working2hard Programming 9 07-28-2004 11:15 AM
setting classpath for java in mdk9.2 perryub Linux - Newbie 2 05-07-2004 05:02 PM
setting java classpath... brutal_brad Linux - Newbie 7 09-21-2003 03:52 PM
ClASSPATH variable for Java oulevon Linux - General 1 02-28-2001 09:25 PM


All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration