LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 03-04-2006, 03:02 PM   #1
JoseVilla
LQ Newbie
 
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Rep: Reputation: 0
JAVA_HOME in /etc/profile doesn't work in GNOME terminal


Hello world.
I wanted the JAVA_HOME environment variable and the JAVA_HOME/bin set for all users in my system (Debian 3.1), so I changed the "/etc/profile" file.
Here's a stract.
Code:
if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi
ANT_HOME="/usr/local/apache-ant-1.6.5"
export ANT_HOME
JAVA_HOME="/usr/java/jdk1.5.0_06"
export JAVA_HOME
PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH
export PATH

umask 022
I go to tty1 and echoing $JAVA_HOME works.
But, with GNOME terminal it doesn't work.
I even restarted my computer.
The strange thing is that I did the same for my Fedora Core 4 and everything goes well.
Please some help, I really need to get rid of this.
 
Old 03-05-2006, 09:07 AM   #2
anti.corp
Member
 
Registered: Nov 2005
Location: Copenhagen
Distribution: Debian E, Vectorlinux 5.1std, Arch, Gentoo 2006.0
Posts: 576

Rep: Reputation: 30
Hi,

Try to alter the second path line so it points to your install dir. Somthing like this:
Code:
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/java/jdk1.5.0_04/bin"
There is also alot of good tutorials concerning this subject. Try to check this one out:
http://wiki.serios.net/wiki/Debian_J...K_installation
 
Old 03-06-2006, 06:59 PM   #3
JoseVilla
LQ Newbie
 
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Original Poster
Rep: Reputation: 0
Thank you for replying and sorry for not having done the same (no Internet on sunday).I'll give it a try tonight and share my results.
 
Old 03-09-2006, 04:30 PM   #4
JoseVilla
LQ Newbie
 
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Original Poster
Rep: Reputation: 0
I tried doing the adding in the second line and it didn't work.
The changes I made were effective in the tty1 but not in the GNOME terminal.
 
Old 03-09-2006, 04:41 PM   #5
g_srinivas
Member
 
Registered: Jul 2005
Location: USA
Distribution: SuSE 9
Posts: 49

Rep: Reputation: 15
Hi, I am not an expert but i recently installed java sdk and for me i installed java in the specified default locations "/opt/jdk1.5.0_06/" and after modification of my /etc/profile, it looks following way:

Code:
if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/opt/jdk1.5.0_06/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/opt/jdk1.5.0_06/bin"
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

export PATH

umask 022

export CLASSPATH=$CLASSPATH:/var/java_dev
Above i set the path purposefully in both path because i wanted to run java for all users. With above settings my java works fine both in tty1 and also in GNOME terminal. Maybe you could try something similar and it might work for you as well.
 
Old 03-24-2006, 12:05 AM   #6
JoseVilla
LQ Newbie
 
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Original Poster
Rep: Reputation: 0
Guess what...I tried your suggestion and the problem is the same. Thanks for your time guys.
I don't know what happens exactly but running
Quote:
source /etc/profile
puts everything in order (JAVA_HOME,ANT_HOME...variables I defined in that file). It seems the profile file is not read.
I have installed Ubuntu on my computer and have the same problem.
I finally managed some way to have my JAVA_HOME and other variables consistently but not much conviniently.

I hope someone could explain why this all happens. I've read a lot about the subject and my case seems to be strange.

Thanks for helping.
 
Old 03-24-2006, 12:19 AM   #7
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
This is what my /etc/profile looks like using Debian Testing:
Code:
if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

export PATH

JAVA_HOME="/usr/lib/java"
export JAVA_HOME

umask 022
The only change I made from it's default set-up was to insert the two lines near the end about JAVA_HOME.
 
Old 04-09-2006, 01:52 AM   #8
JoseVilla
LQ Newbie
 
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Original Poster
Rep: Reputation: 0
I finally got it.
The solution was understanding what a login shell is.
When in ttyx you use a login shell while when a gnome terminal (pts) you use a non login shell. So I had to do the exporting of variables in the /etc/bash.bashrc (for no login shells) and /etc/profile (for login shells) files.
Now it works!!!

For a more detail explanation look at:
http://telin.ugent.be/~slippens/drup...hrc_and_others

Thanks for your time and help

Last edited by JoseVilla; 04-09-2006 at 01:53 AM.
 
  


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
Gnome-terminal does not work well as a BBS client ljx980645 Linux - Software 1 02-20-2006 11:52 AM
gnome-terminal won't work after update mcgrew Linux - General 2 05-16-2005 04:57 AM
Changing bash profile doesn't affect new terminal windows... SAFX Linux - Newbie 5 10-12-2004 12:51 PM
gnome-terminal profile errors Dancingsalad Linux - General 0 05-09-2004 01:37 AM
Terminal profile Phaethar Red Hat 1 11-21-2003 01:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:09 PM.

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