Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
hi all i m using fedora core 4 linux i have installed j2sdk1.4.2_11 and jboss4.0.2 on it my problem is i have to set path every time for j2sdk1.4.2_11 to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2006
    Posts
    22

    how to set Path Environment permanently


    hi all
    i m using fedora core 4 linux
    i have installed j2sdk1.4.2_11 and jboss4.0.2 on it
    my problem is i have to set path every time for j2sdk1.4.2_11 to get jboss working. i use this command for it:
    #JAVA_HOME="/usr/java/j2sdk1.4.2_11"
    #export JAVA_HOME
    then i type
    #printenv
    i get the path in the output of this command
    but wen i stop jboss and again want to start the jboss
    but b4 starting jboss i again have to type the above commands
    can some1 plz tell me how can i set path permanently for this or anything
    so that i dont have to give this command again n again
    plz keep in mind that i m completely new to this world
    so plz tell me in detail as much as u can
    thnx
    regards

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    hi anshul !!!

    in your home folder, enable View --> Show Hidden Files....
    open .bash_profile file, before export PATH line, add this line.....

    PATH=$PATH:JAVA_HOME="/usr/java/j2sdk1.4.2_11

    logout and login again...... check if its working ... well ! it should work.....
    Last edited by devils casper; 01-02-2008 at 08:57 AM. Reason: removed extra signature
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    mzq
    mzq is offline
    Just Joined!
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    26
    Shouldn't you add this line to the ~/.bashrc (or ~/.zshrc etc., respectively, if using another shell) instead of the ~/.bash_profile?

  4. #4
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    hi mzq !!

    in a few cases, .bashrc does not exist... and .bash_profile is the first file which get executed when user logs in. this .bash_profile file check the existance of .bashrc file and execute that....
    so which one is better ?????...... .bashrc or .bash_profile
    Last edited by devils casper; 01-02-2008 at 08:57 AM.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  5. #5
    mzq
    mzq is offline
    Just Joined!
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    26
    Hi devils_casper,

    hmm, I'm using zsh....

    My ~/.bash_profile contains only one line and a few comments.

    # This file is sourced by bash for login shells. The following line
    # runs your .bashrc and is recommended by the bash info pages.
    [[ -f ~/.bashrc ]] && . ~/.bashrc

    The ~/.bashrc instead contains much more information, like window titles of terms and bash completion etc. and aliases, even though ~/.alias is also parsed.

    I think, in the end it doesn't matter where you add the export line, for both files (~/.bashrc and ~/.bash_profile) are executed, but I prefer to add all changes to one file...

    EDIT:

    My ~/.bashrc export line:
    export PATH=/opt/jdk1.5.0_06/bin/:/opt/eclipse:$PATH

  6. #6
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    hi mzq !!!

    [[ -f ~/.bashrc ]] && . ~/.bashrc
    whats this line does ???? it checks the existance of .bashrc file....
    these are the contents of .bashrc file..

    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi
    it checks the existance of /etc/bashrc and then execute that file......
    this /etc/bashrc is global file, common for all users and set environment variables....

    well !! it depends where you put and set user specific variables... i prefer .bash_profile only.....

    i am using FC5, Debian, SuSe 10.1, Mandriva and Slax....
    Last edited by devils casper; 01-02-2008 at 08:57 AM.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  7. #7
    Just Joined!
    Join Date
    Aug 2006
    Posts
    22
    dear mzq and casper
    thnx for ur replies
    i got the solutions
    i dont know much bout wat's going on i mean which file does wat
    but wat i did is
    i put
    PATH=$PATH:$JAVA_HOME="/usr/java/j2sdk1.4.2_11 in /root/.bash_profile
    so now i dont have to put
    PATH=$PATH:$JAVA_HOME="/usr/java/j2sdk1.4.2_11
    export PATH
    anymore
    i also read in some forums
    if u want to set PATH for all users expect root
    u'll have to edit /etc/profile
    coz here u can set system wide environment and startup progrms
    wat i understood i wrote
    if is there any mistake please let me know coz i want to learn linux more n more this is really a rocking stuff
    thnx
    cheers
    Quote Originally Posted by devils_casper
    hi mzq !!!



    whats this line does ???? it checks the existance of .bashrc file....
    these are the contents of .bashrc file..



    it checks the existance of /etc/bashrc and then execute that file......
    this /etc/bashrc is global file, comman for all users and set environment variables....

    well !! it depends where you put and set user specific variables... i prefer .bash_profile only.....

    i am using FC5, Debian, SuSe 10.1, Mandriva and Slax....
    Last edited by devils casper; 01-02-2008 at 08:58 AM.

  8. #8
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    hi anshul !!!

    Quote Originally Posted by anshul
    u'll have to edit /etc/profile
    coz here u can set system wide environment and startup progrms
    wat i understood i wrote
    if is there any mistake please let me know coz i want to learn linux more n more this is really a rocking stuff
    you are right..... for setting variables for all users, you have to edit /etc/profile or /etc/bahsrc
    Last edited by devils casper; 01-02-2008 at 08:56 AM.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  9. #9
    Just Joined!
    Join Date
    Aug 2006
    Posts
    22
    thnx n regards

    cheers

  10. #10
    Just Joined!
    Join Date
    Aug 2006
    Posts
    22

    Arrow PATH Environment Problem

    hi all
    i set some path for j2sdk1.4.2_11 like this in /root/.bash_profile
    PATH=$PATH:$JAVA_HOME=/usr/java/j2sdk1.4.2_11
    after putting PATH I didnt need to type it everytime
    So i was able to start the service by giving the simple command
    #sh run.sh
    some time back i was doing some thing
    then something happened wrong
    i mean now again i have to set PATH EVERYTIME
    i checked my /root/.bash_profile
    it shows PATH there
    please help me to come out from this problem
    thnx n regards

    ch

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •