Fedora Linux Support Community & Resources Center
  #1  
Old 3rd May 2011, 06:48 PM
vefoda Offline
Registered User
 
Join Date: Mar 2011
Posts: 51
linuxfedorafirefox
Question How to set environment variables permenently?

How to set JAVA_HOME environment variables permanently such that it will not have to be set each time it has to be used
  #2  
Old 3rd May 2011, 06:53 PM
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,810
linuxfirefox
Re: How to set environment variables permenently?

Quote:
Originally Posted by vefoda View Post
How to set JAVA_HOME environment variables permanently such that it will not have to be set each time it has to be used
In your home directory, edit .bashrc to add this line

Quote:
export JAVA_HOME=/usr/java/latest
or substitute whatever your JAVA_HOME is where I put /usr/java/latest.

Any future bash shell launched will have that JAVA_HOME
  #3  
Old 3rd May 2011, 07:02 PM
vefoda Offline
Registered User
 
Join Date: Mar 2011
Posts: 51
linuxfedorafirefox
Re: How to set environment variables permenently?

How to edit .bashrc to add the line
Quote:
export JAVA_HOME=/usr/java/latest
  #4  
Old 3rd May 2011, 11:02 PM
bodhi.zazen Offline
Registered User
 
Join Date: Jul 2006
Location: Montana
Posts: 731
unknownunknown
Re: How to set environment variables permenently?

Quote:
Originally Posted by vefoda View Post
How to edit .bashrc to add the line
You can also add that to .bash_profile (might be a better choice).

Use any editor and add that line at the bottom.

Code:
gedit ~/.bashrc
you can use nano, vim, emacs ....
__________________
If it is not broken, tweak it... If you break Fedora you get to keep both pieces :p
  #5  
Old 6th May 2011, 10:21 AM
Les62 Offline
Registered User
 
Join Date: Nov 2010
Posts: 4
linuxfedorafirefox
Re: How to set environment variables permenently?

Rather than putting it in your home directory .bashrc, I would put it into /etc/bashrc That way the variable will be available for all users (root included).
  #6  
Old 6th May 2011, 10:42 AM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 967
linuxfedorafirefox
Re: How to set environment variables permenently?

Quote:
Originally Posted by Les62 View Post
Rather than putting it in your home directory .bashrc, I would put it into /etc/bashrc That way the variable will be available for all users (root included).
I believe the "approved" way of doing this for the whole system is to create a new file in /etc/profile.d/ rather than editing /etc/bashrc directly. (If you edit /etc/bashrc and bash is updated, you might get your edits overwritten, or you might not get the file updated.)

So: run
Code:
su -c 'gedit /etc/profile.d/my-java-environment.sh'
enter the line listed above by vefonda, save and exit.

Changes to your own profile or the system profile will only affect new shells, so to see the effect you can just close the current terminal window, and open a new one (or log out and in again).
  #7  
Old 11th April 2016, 10:45 PM
maskfireclaw Offline
Registered User
 
Join Date: Apr 2016
Location: United States
Posts: 1
linuxfedorachrome
Re: How to set environment variables permenently?

Quote:
Originally Posted by marriedto51 View Post
I believe the "approved" way of doing this for the whole system is to create a new file in /etc/profile.d/ rather than editing /etc/bashrc directly. (If you edit /etc/bashrc and bash is updated, you might get your edits overwritten, or you might not get the file updated.)

So: run
Code:
su -c 'gedit /etc/profile.d/my-java-environment.sh'
enter the line listed above by vefonda, save and exit.

Changes to your own profile or the system profile will only affect new shells, so to see the effect you can just close the current terminal window, and open a new one (or log out and in again).
Please be careful if you take this course of action, I tried this and apparently made an error. My laptop wouldn't login and only recognized basic bash commands, if this happens boot fedora with text only, login to root user and use 'command -p rm <path-to-file>' to erase it.
  #8  
Old 11th April 2016, 11:40 PM
antikythera Offline
Community Manager
 
Join Date: Dec 2013
Location: United Kingdom
Posts: 2,195
linuxchrome
Re: How to set environment variables permenently?

Please be even more careful following advice in old forum threads from 2011. If you need assistance with Java issues with the current version of Fedora please open a new thread.
__________________
Fedora 24 Alpha MATE¦Fujitsu LIFEBOOK A512 - Intel Core i3-3110M, 16GB Crucial DDR3-1600 Kit, 500GB WD Blue WD5000LPVX, Samsung SN-208FB, Centrino Wireless-N 2230 (bgn + bluetooth), Startech 2 Port USB 3.0 ExpressCard (ECUSB3S254F)
Fedora 23 MATE¦Gigabyte GA-AM1M-S2H, Athlon 5350, 8GB Corsair Vengeance CML8GX3M2A1600C9 LP Kit (XMP mode), Seagate ST1000DM003, HL-DT-ST DVDRAM GH24NSB
Closed Thread

Tags
environment variables, java_home, permanently

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set environment variables? Seedrick Using Fedora 3 23rd May 2010 01:47 PM
Environment Variables nightmarcus Using Fedora 5 20th January 2009 12:31 PM
Environment Variables Curtor Using Fedora 4 14th February 2008 09:01 PM
environment variables? hari_mj23 Using Fedora 9 3rd April 2006 07:03 AM
Environment variables Flatron Using Fedora 7 28th January 2006 03:47 AM


Current GMT-time: 08:44 (Monday, 30-05-2016)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat