How do I set environment variables?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
72
down vote
favorite
I'm trying to set up Apache Tomcat on my pc, and it wants me to set up an environment variable for CATALINA_HOME
. Does any know how to do this?
environment-variables
add a comment |Â
up vote
72
down vote
favorite
I'm trying to set up Apache Tomcat on my pc, and it wants me to set up an environment variable for CATALINA_HOME
. Does any know how to do this?
environment-variables
add a comment |Â
up vote
72
down vote
favorite
up vote
72
down vote
favorite
I'm trying to set up Apache Tomcat on my pc, and it wants me to set up an environment variable for CATALINA_HOME
. Does any know how to do this?
environment-variables
I'm trying to set up Apache Tomcat on my pc, and it wants me to set up an environment variable for CATALINA_HOME
. Does any know how to do this?
environment-variables
edited Nov 27 '10 at 10:27
Roger Light
1,249920
1,249920
asked Aug 3 '10 at 16:31
jumpnett
2,52172843
2,52172843
add a comment |Â
add a comment |Â
6 Answers
6
active
oldest
votes
up vote
72
down vote
accepted
In bash you can set variables like this:
export CATALINA_HOME=/opt/catalina
most other shells follow this convention, but not all. You can set it permanently in ~/.profile
for bash (and as before, other shells have other locations)
- https://help.ubuntu.com/community/EnvironmentVariables
- Where to declare environment variables?
6
for session-wide variables, help.ubuntu.com recommends~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.
â McDowell
Aug 4 '10 at 21:49
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
4
Setting it in~/.profile
doesn't work for me. It works in~/.bashrc
though.
â jumpnett
Aug 7 '10 at 0:56
Setting it in~/.bash_profile
works as well.
â jumpnett
Jan 31 '13 at 0:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
 |Â
show 1 more comment
up vote
23
down vote
Environment variables should already work
If you are using the tomcat6 package from the Ubuntu repositories, then the CATALINA_HOME and other environment variables are already set, in the /etc/init.d/tomcat6
startup script.
If you are installing tomcat outside the package manager (hopefully in /opt or somewhere else outside the managed file system), then running the TOMCAT/bin/startup.sh
should use the relative location to define the CATALINA_HOME.
Setting the Environment variable
If for some reason you still need to set an environment variable you can open a terminal window and type in the command:
export CATALINA_HOME=/path/to/the/root/folder/of/tomcat
This environment variable will now work within that terminal window, but if you open another window or logout/login you loose that setting.
Make the environment variable permanent
To make the environment variable setting permanent, there are several places you can define the setting.
To be really sure the setting is being picked up, add the above setting to one of the startup script for tomcat:
yourtomcatfolder/bin/startup.sh
yourtomcatfolder/bin/catalina.sh
Note: startup.sh calls the catalina.sh. You should add the setting at the start of one of these files (after any initial comments)
The standard way for global environment variables would be to add an entry in /etc/environment
(you do not use the command export in this file as it is not a normal bash script)
CATALINA_HOME=/path/to/the/root/folder/of/tomcat
Not recommended
You can set the environment variables in the bash (command line shell) configuration files, but these are not recommended as they are not always picked up (eg. if you are running a server that you dont login to to run tomcat):
~/.bashrc |
~/.profile |
/etc.bash.bashrc |
/etc/profile
4
It should not be thestartup
orcatalina
scripts, but thesetenv.sh
orsetenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)
â Olathe
Oct 5 '13 at 0:53
add a comment |Â
up vote
10
down vote
To set permanent environment variables in latest Ubuntu versions (from 14.04 and above)
add the variables to /etc/environment
. For that follow the below instructions,
Open the terminal and run
sudo -H gedit /etc/environment
the provide your password, then in the prompted text file
then add the variables like
ANT_HOME="/opt/ANT/"
Sample of the /etc/environment
is given below
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-oracle/"
AXIS2_HOME="/opt/axis2-1.7.4/"
ANT_HOME="/opt/apache-ant-1.9.7/"
add a comment |Â
up vote
6
down vote
The best place for this depends on how and where you've installed Tomcat, what applications you want to pick up this setting and how global you want the scope to be.
The Ubuntu documentation on Environment Variables discusses the pros and cons of the various options.
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
add a comment |Â
up vote
2
down vote
nano ~/.bashrc
This will most likely contain quite a bit of data already. Most of the definitions here are for setting bash options, which are unrelated to environmental variables. You can set environmental variables just like you would from the command line:
export VARNAME=value
LINK
I tested it on Ubuntu 16.04. Works great.
add a comment |Â
up vote
1
down vote
After going through Ubuntu Documentation on Environment Variables, I came up with following workaround:
##Save & run the following in a shell script,
export ENVIRON_VAR_NAME = Value
# any other initializations like
export PATH=$PWD:$PATH
bash
The last line creates a child shell, which inherits Environment Variable values from parent shell (which have just been set).
add a comment |Â
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
72
down vote
accepted
In bash you can set variables like this:
export CATALINA_HOME=/opt/catalina
most other shells follow this convention, but not all. You can set it permanently in ~/.profile
for bash (and as before, other shells have other locations)
- https://help.ubuntu.com/community/EnvironmentVariables
- Where to declare environment variables?
6
for session-wide variables, help.ubuntu.com recommends~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.
â McDowell
Aug 4 '10 at 21:49
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
4
Setting it in~/.profile
doesn't work for me. It works in~/.bashrc
though.
â jumpnett
Aug 7 '10 at 0:56
Setting it in~/.bash_profile
works as well.
â jumpnett
Jan 31 '13 at 0:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
 |Â
show 1 more comment
up vote
72
down vote
accepted
In bash you can set variables like this:
export CATALINA_HOME=/opt/catalina
most other shells follow this convention, but not all. You can set it permanently in ~/.profile
for bash (and as before, other shells have other locations)
- https://help.ubuntu.com/community/EnvironmentVariables
- Where to declare environment variables?
6
for session-wide variables, help.ubuntu.com recommends~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.
â McDowell
Aug 4 '10 at 21:49
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
4
Setting it in~/.profile
doesn't work for me. It works in~/.bashrc
though.
â jumpnett
Aug 7 '10 at 0:56
Setting it in~/.bash_profile
works as well.
â jumpnett
Jan 31 '13 at 0:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
 |Â
show 1 more comment
up vote
72
down vote
accepted
up vote
72
down vote
accepted
In bash you can set variables like this:
export CATALINA_HOME=/opt/catalina
most other shells follow this convention, but not all. You can set it permanently in ~/.profile
for bash (and as before, other shells have other locations)
- https://help.ubuntu.com/community/EnvironmentVariables
- Where to declare environment variables?
In bash you can set variables like this:
export CATALINA_HOME=/opt/catalina
most other shells follow this convention, but not all. You can set it permanently in ~/.profile
for bash (and as before, other shells have other locations)
- https://help.ubuntu.com/community/EnvironmentVariables
- Where to declare environment variables?
edited Apr 13 '17 at 12:23
Communityâ¦
1
1
answered Aug 3 '10 at 16:34
Ressu
7,94012927
7,94012927
6
for session-wide variables, help.ubuntu.com recommends~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.
â McDowell
Aug 4 '10 at 21:49
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
4
Setting it in~/.profile
doesn't work for me. It works in~/.bashrc
though.
â jumpnett
Aug 7 '10 at 0:56
Setting it in~/.bash_profile
works as well.
â jumpnett
Jan 31 '13 at 0:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
 |Â
show 1 more comment
6
for session-wide variables, help.ubuntu.com recommends~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.
â McDowell
Aug 4 '10 at 21:49
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
4
Setting it in~/.profile
doesn't work for me. It works in~/.bashrc
though.
â jumpnett
Aug 7 '10 at 0:56
Setting it in~/.bash_profile
works as well.
â jumpnett
Jan 31 '13 at 0:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
6
6
for session-wide variables, help.ubuntu.com recommends
~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.â McDowell
Aug 4 '10 at 21:49
for session-wide variables, help.ubuntu.com recommends
~/.profile
as probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.â McDowell
Aug 4 '10 at 21:49
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
Updated the answer. The reason why i used .bashrc instead was that at some point .profile wasn't sourced automatically. But if it works now, it's better to use it.
â Ressu
Aug 5 '10 at 5:07
4
4
Setting it in
~/.profile
doesn't work for me. It works in ~/.bashrc
though.â jumpnett
Aug 7 '10 at 0:56
Setting it in
~/.profile
doesn't work for me. It works in ~/.bashrc
though.â jumpnett
Aug 7 '10 at 0:56
Setting it in
~/.bash_profile
works as well.â jumpnett
Jan 31 '13 at 0:45
Setting it in
~/.bash_profile
works as well.â jumpnett
Jan 31 '13 at 0:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
There is also a system wide file in /etc. This works but is per user.
â wheredidthatnamecomefrom
Nov 25 '17 at 18:45
 |Â
show 1 more comment
up vote
23
down vote
Environment variables should already work
If you are using the tomcat6 package from the Ubuntu repositories, then the CATALINA_HOME and other environment variables are already set, in the /etc/init.d/tomcat6
startup script.
If you are installing tomcat outside the package manager (hopefully in /opt or somewhere else outside the managed file system), then running the TOMCAT/bin/startup.sh
should use the relative location to define the CATALINA_HOME.
Setting the Environment variable
If for some reason you still need to set an environment variable you can open a terminal window and type in the command:
export CATALINA_HOME=/path/to/the/root/folder/of/tomcat
This environment variable will now work within that terminal window, but if you open another window or logout/login you loose that setting.
Make the environment variable permanent
To make the environment variable setting permanent, there are several places you can define the setting.
To be really sure the setting is being picked up, add the above setting to one of the startup script for tomcat:
yourtomcatfolder/bin/startup.sh
yourtomcatfolder/bin/catalina.sh
Note: startup.sh calls the catalina.sh. You should add the setting at the start of one of these files (after any initial comments)
The standard way for global environment variables would be to add an entry in /etc/environment
(you do not use the command export in this file as it is not a normal bash script)
CATALINA_HOME=/path/to/the/root/folder/of/tomcat
Not recommended
You can set the environment variables in the bash (command line shell) configuration files, but these are not recommended as they are not always picked up (eg. if you are running a server that you dont login to to run tomcat):
~/.bashrc |
~/.profile |
/etc.bash.bashrc |
/etc/profile
4
It should not be thestartup
orcatalina
scripts, but thesetenv.sh
orsetenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)
â Olathe
Oct 5 '13 at 0:53
add a comment |Â
up vote
23
down vote
Environment variables should already work
If you are using the tomcat6 package from the Ubuntu repositories, then the CATALINA_HOME and other environment variables are already set, in the /etc/init.d/tomcat6
startup script.
If you are installing tomcat outside the package manager (hopefully in /opt or somewhere else outside the managed file system), then running the TOMCAT/bin/startup.sh
should use the relative location to define the CATALINA_HOME.
Setting the Environment variable
If for some reason you still need to set an environment variable you can open a terminal window and type in the command:
export CATALINA_HOME=/path/to/the/root/folder/of/tomcat
This environment variable will now work within that terminal window, but if you open another window or logout/login you loose that setting.
Make the environment variable permanent
To make the environment variable setting permanent, there are several places you can define the setting.
To be really sure the setting is being picked up, add the above setting to one of the startup script for tomcat:
yourtomcatfolder/bin/startup.sh
yourtomcatfolder/bin/catalina.sh
Note: startup.sh calls the catalina.sh. You should add the setting at the start of one of these files (after any initial comments)
The standard way for global environment variables would be to add an entry in /etc/environment
(you do not use the command export in this file as it is not a normal bash script)
CATALINA_HOME=/path/to/the/root/folder/of/tomcat
Not recommended
You can set the environment variables in the bash (command line shell) configuration files, but these are not recommended as they are not always picked up (eg. if you are running a server that you dont login to to run tomcat):
~/.bashrc |
~/.profile |
/etc.bash.bashrc |
/etc/profile
4
It should not be thestartup
orcatalina
scripts, but thesetenv.sh
orsetenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)
â Olathe
Oct 5 '13 at 0:53
add a comment |Â
up vote
23
down vote
up vote
23
down vote
Environment variables should already work
If you are using the tomcat6 package from the Ubuntu repositories, then the CATALINA_HOME and other environment variables are already set, in the /etc/init.d/tomcat6
startup script.
If you are installing tomcat outside the package manager (hopefully in /opt or somewhere else outside the managed file system), then running the TOMCAT/bin/startup.sh
should use the relative location to define the CATALINA_HOME.
Setting the Environment variable
If for some reason you still need to set an environment variable you can open a terminal window and type in the command:
export CATALINA_HOME=/path/to/the/root/folder/of/tomcat
This environment variable will now work within that terminal window, but if you open another window or logout/login you loose that setting.
Make the environment variable permanent
To make the environment variable setting permanent, there are several places you can define the setting.
To be really sure the setting is being picked up, add the above setting to one of the startup script for tomcat:
yourtomcatfolder/bin/startup.sh
yourtomcatfolder/bin/catalina.sh
Note: startup.sh calls the catalina.sh. You should add the setting at the start of one of these files (after any initial comments)
The standard way for global environment variables would be to add an entry in /etc/environment
(you do not use the command export in this file as it is not a normal bash script)
CATALINA_HOME=/path/to/the/root/folder/of/tomcat
Not recommended
You can set the environment variables in the bash (command line shell) configuration files, but these are not recommended as they are not always picked up (eg. if you are running a server that you dont login to to run tomcat):
~/.bashrc |
~/.profile |
/etc.bash.bashrc |
/etc/profile
Environment variables should already work
If you are using the tomcat6 package from the Ubuntu repositories, then the CATALINA_HOME and other environment variables are already set, in the /etc/init.d/tomcat6
startup script.
If you are installing tomcat outside the package manager (hopefully in /opt or somewhere else outside the managed file system), then running the TOMCAT/bin/startup.sh
should use the relative location to define the CATALINA_HOME.
Setting the Environment variable
If for some reason you still need to set an environment variable you can open a terminal window and type in the command:
export CATALINA_HOME=/path/to/the/root/folder/of/tomcat
This environment variable will now work within that terminal window, but if you open another window or logout/login you loose that setting.
Make the environment variable permanent
To make the environment variable setting permanent, there are several places you can define the setting.
To be really sure the setting is being picked up, add the above setting to one of the startup script for tomcat:
yourtomcatfolder/bin/startup.sh
yourtomcatfolder/bin/catalina.sh
Note: startup.sh calls the catalina.sh. You should add the setting at the start of one of these files (after any initial comments)
The standard way for global environment variables would be to add an entry in /etc/environment
(you do not use the command export in this file as it is not a normal bash script)
CATALINA_HOME=/path/to/the/root/folder/of/tomcat
Not recommended
You can set the environment variables in the bash (command line shell) configuration files, but these are not recommended as they are not always picked up (eg. if you are running a server that you dont login to to run tomcat):
~/.bashrc |
~/.profile |
/etc.bash.bashrc |
/etc/profile
answered Aug 5 '10 at 7:03
jr0cket
2,67311413
2,67311413
4
It should not be thestartup
orcatalina
scripts, but thesetenv.sh
orsetenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)
â Olathe
Oct 5 '13 at 0:53
add a comment |Â
4
It should not be thestartup
orcatalina
scripts, but thesetenv.sh
orsetenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)
â Olathe
Oct 5 '13 at 0:53
4
4
It should not be the
startup
or catalina
scripts, but the setenv.sh
or setenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)â Olathe
Oct 5 '13 at 0:53
It should not be the
startup
or catalina
scripts, but the setenv.sh
or setenv.bat
script, creating it if needed: "Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable." (Running The Apache Tomcat 7.0 Servlet/JSP Container, Section 3.4)â Olathe
Oct 5 '13 at 0:53
add a comment |Â
up vote
10
down vote
To set permanent environment variables in latest Ubuntu versions (from 14.04 and above)
add the variables to /etc/environment
. For that follow the below instructions,
Open the terminal and run
sudo -H gedit /etc/environment
the provide your password, then in the prompted text file
then add the variables like
ANT_HOME="/opt/ANT/"
Sample of the /etc/environment
is given below
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-oracle/"
AXIS2_HOME="/opt/axis2-1.7.4/"
ANT_HOME="/opt/apache-ant-1.9.7/"
add a comment |Â
up vote
10
down vote
To set permanent environment variables in latest Ubuntu versions (from 14.04 and above)
add the variables to /etc/environment
. For that follow the below instructions,
Open the terminal and run
sudo -H gedit /etc/environment
the provide your password, then in the prompted text file
then add the variables like
ANT_HOME="/opt/ANT/"
Sample of the /etc/environment
is given below
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-oracle/"
AXIS2_HOME="/opt/axis2-1.7.4/"
ANT_HOME="/opt/apache-ant-1.9.7/"
add a comment |Â
up vote
10
down vote
up vote
10
down vote
To set permanent environment variables in latest Ubuntu versions (from 14.04 and above)
add the variables to /etc/environment
. For that follow the below instructions,
Open the terminal and run
sudo -H gedit /etc/environment
the provide your password, then in the prompted text file
then add the variables like
ANT_HOME="/opt/ANT/"
Sample of the /etc/environment
is given below
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-oracle/"
AXIS2_HOME="/opt/axis2-1.7.4/"
ANT_HOME="/opt/apache-ant-1.9.7/"
To set permanent environment variables in latest Ubuntu versions (from 14.04 and above)
add the variables to /etc/environment
. For that follow the below instructions,
Open the terminal and run
sudo -H gedit /etc/environment
the provide your password, then in the prompted text file
then add the variables like
ANT_HOME="/opt/ANT/"
Sample of the /etc/environment
is given below
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-oracle/"
AXIS2_HOME="/opt/axis2-1.7.4/"
ANT_HOME="/opt/apache-ant-1.9.7/"
edited Nov 16 '16 at 5:18
muru
128k19269459
128k19269459
answered Nov 16 '16 at 5:11
![](https://lh4.googleusercontent.com/-i8lMihc1yYc/AAAAAAAAAAI/AAAAAAAAAJE/ooPD4M12q8I/photo.jpg?sz=32)
![](https://lh4.googleusercontent.com/-i8lMihc1yYc/AAAAAAAAAAI/AAAAAAAAAJE/ooPD4M12q8I/photo.jpg?sz=32)
Kasun Siyambalapitiya
283515
283515
add a comment |Â
add a comment |Â
up vote
6
down vote
The best place for this depends on how and where you've installed Tomcat, what applications you want to pick up this setting and how global you want the scope to be.
The Ubuntu documentation on Environment Variables discusses the pros and cons of the various options.
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
add a comment |Â
up vote
6
down vote
The best place for this depends on how and where you've installed Tomcat, what applications you want to pick up this setting and how global you want the scope to be.
The Ubuntu documentation on Environment Variables discusses the pros and cons of the various options.
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
add a comment |Â
up vote
6
down vote
up vote
6
down vote
The best place for this depends on how and where you've installed Tomcat, what applications you want to pick up this setting and how global you want the scope to be.
The Ubuntu documentation on Environment Variables discusses the pros and cons of the various options.
The best place for this depends on how and where you've installed Tomcat, what applications you want to pick up this setting and how global you want the scope to be.
The Ubuntu documentation on Environment Variables discusses the pros and cons of the various options.
answered Aug 3 '10 at 22:17
McDowell
253612
253612
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
add a comment |Â
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
What are you referring to when you say, "best place for this"?
â jumpnett
Aug 3 '10 at 22:58
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
@jumpnett - I mean where to make the setting persistent so that it is always available to the applications depending on it. Unless you're happy typing the setting in every time or want to write your own script.
â McDowell
Aug 4 '10 at 21:44
add a comment |Â
up vote
2
down vote
nano ~/.bashrc
This will most likely contain quite a bit of data already. Most of the definitions here are for setting bash options, which are unrelated to environmental variables. You can set environmental variables just like you would from the command line:
export VARNAME=value
LINK
I tested it on Ubuntu 16.04. Works great.
add a comment |Â
up vote
2
down vote
nano ~/.bashrc
This will most likely contain quite a bit of data already. Most of the definitions here are for setting bash options, which are unrelated to environmental variables. You can set environmental variables just like you would from the command line:
export VARNAME=value
LINK
I tested it on Ubuntu 16.04. Works great.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
nano ~/.bashrc
This will most likely contain quite a bit of data already. Most of the definitions here are for setting bash options, which are unrelated to environmental variables. You can set environmental variables just like you would from the command line:
export VARNAME=value
LINK
I tested it on Ubuntu 16.04. Works great.
nano ~/.bashrc
This will most likely contain quite a bit of data already. Most of the definitions here are for setting bash options, which are unrelated to environmental variables. You can set environmental variables just like you would from the command line:
export VARNAME=value
LINK
I tested it on Ubuntu 16.04. Works great.
answered Jan 3 at 11:00
Sunny127
17113
17113
add a comment |Â
add a comment |Â
up vote
1
down vote
After going through Ubuntu Documentation on Environment Variables, I came up with following workaround:
##Save & run the following in a shell script,
export ENVIRON_VAR_NAME = Value
# any other initializations like
export PATH=$PWD:$PATH
bash
The last line creates a child shell, which inherits Environment Variable values from parent shell (which have just been set).
add a comment |Â
up vote
1
down vote
After going through Ubuntu Documentation on Environment Variables, I came up with following workaround:
##Save & run the following in a shell script,
export ENVIRON_VAR_NAME = Value
# any other initializations like
export PATH=$PWD:$PATH
bash
The last line creates a child shell, which inherits Environment Variable values from parent shell (which have just been set).
add a comment |Â
up vote
1
down vote
up vote
1
down vote
After going through Ubuntu Documentation on Environment Variables, I came up with following workaround:
##Save & run the following in a shell script,
export ENVIRON_VAR_NAME = Value
# any other initializations like
export PATH=$PWD:$PATH
bash
The last line creates a child shell, which inherits Environment Variable values from parent shell (which have just been set).
After going through Ubuntu Documentation on Environment Variables, I came up with following workaround:
##Save & run the following in a shell script,
export ENVIRON_VAR_NAME = Value
# any other initializations like
export PATH=$PWD:$PATH
bash
The last line creates a child shell, which inherits Environment Variable values from parent shell (which have just been set).
edited Nov 16 '16 at 5:19
muru
128k19269459
128k19269459
answered Feb 19 '14 at 1:53
Ashish Sadhwani
111
111
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f730%2fhow-do-i-set-environment-variables%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password