aspose file tools*
The moose likes Linux / UNIX and the fly likes where is the file that we can add/edit env parameters in it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "where is the file that we can add/edit env parameters in it?" Watch "where is the file that we can add/edit env parameters in it?" New topic
Author

where is the file that we can add/edit env parameters in it?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
Hi
Thank you for reading my post.
outcome of env command in my linux environment shows that there are some jre in the path and also some other variables point ot old jre which come with Linux distro.

now i want to find the file that includes these env variable to edit some of them and add new parameter to it.

i know that i can use export command to export an env variable.
what i do not know is:
does export command save that variable for later use?
for example if i execute export java_home= /opt/java/
will it remain in be present next time i log into linux or i should execute that command each time?

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

/etc/profile is the global one.

For individual users it could be (in the user's home directory):
.bash_profile
.profile
.bashrc

depending on what flavor or Linux you're using.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Raminaa,
Exports from the command line are not remembered across sessions. A common alternative is to put the export in your .profile file (in your home directory) or the equivalent file for your shell.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Ben beat me to a response . Conveniently, we gave different variants on the answer!
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
All the above looks good for Redhat/CentOS and many other distros.

There are Debian flavored distros (Ubuntu is one), where /etc/profile is not really the best place to adjust system wide PATH, and introduce new system wide environment variables. Look at /etc/environment.

For personal tailoring, if you use Gnome and a graphical login e.g., none of .bash_profile, .profile, ...... is even used AFAIK. Create a file in your home directory named .gnomerc instead.

Guy
raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
Hi
Thank you all for reply.
home/raminaa/. was vry usefull and now i can add new variables like ant_home and others there.
but none of already defined variable could be found in any of mentioned files.
.bash_profile
.profile
.bashrc
/etc/profile
/etc/environment

but now i have a good understanding about environment files.

I should say that i use KDE, i prefer it over Gnome because i find it easier to handle as there are more similarities between redmond stuff and kde.
thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Raminaa,
The already defined variables have been already defined for you by the system. (I didn't mean for that sentence to be as circular as it came out.)

You can append the existing values in your .profile or equivalent file.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

And some are set in /etc/default/.

And the command should be:

because:
a) we're case-sensitive.
b) trailing slashes aren't handy. If you try to extend the path, you would have to use:

c) a blank is sometimes fatal - here it is:


http://home.arcor.de/hirnstrom/bewerbung
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

In linux, when you spawn a shell child process, there are a number of rules regarding environment variables. The exact set of rules that applies will depend on what shell you are using and what options you used when spawning the shell child.

In bash - the usual default shell for Linux users, environment variables defined in the parent shell will be local to that shell - they will not be inherited by its children. However, the "export" command will allow you to select environment variables whose names and values will be inherited. Such as JAVA_HOME, PATH, and ANT_HOME.

The issue goes both ways. You can't call a sub-script to set environment variables, because export is a parent-to-child relationship. However, it's often useful to have configuration scripts that a parent script can invoke to get info from. In RedHat-style linux distros, this is seen frequently, in the /etc/init.d directory, since their approach is to consider initscripts as immutable, getting their config info from the /etc parameter directories.

To permit this uphill information flow, there's a process known as "sourcing". The command itself is "source" - more commonly simply written as ". " - note the space that makes the dot a command itself rather than simply the first character of some other command.

Sourced files set environment variables that will be passed back to their callers. This is how your login process can call things like /etc/profile and ~/.bash_profile and set environment variables for your shells. They source them.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where is the file that we can add/edit env parameters in it?
 
Similar Threads
Java on Linux
Hello
Setting Enviroment variables inside a shell
Two versions of Java installed
XWindows error