I just downloaded maven, to install it, I am setting environment variables using command line as described in documentation
我刚刚下载了maven,要安装它,我正在使用命令行设置环境变量,如文档中所述
export M2_HOME=/home/vishal/java/install/apache-maven
export M2=$M2_HOME/bin
PATH=$M2:$PATH
After this, I am able to check the maven version using mvn --version.
在此之后,我可以使用mvn --version检查maven版本。
But if I exit the command prompt and again launch it and type
但是,如果我退出命令提示符并再次启动它并键入
mvn --version
It does not work. If I again set environment variables, it works temporarily.
这是行不通的。如果我再次设置环境变量,它会暂时起作用。
I tried adding environment variable in /etc/environment files also but still it does not work.
我尝试在/ etc / environment文件中添加环境变量,但它仍然不起作用。
2 个解决方案
#1
0
You could add them to your .bashrc file in your home directory.
您可以将它们添加到主目录中的.bashrc文件中。
gedit ~/.bashrc
Add the lines you need at the end of the file, exactly as you were entering them before. The file is executed every time you open a new terminal. It will have the same effect as manually entering the commands every time you open a new shell.
在文件末尾添加所需的行,与之前输入的行完全相同。每次打开新终端时都会执行该文件。它与每次打开新shell时手动输入命令具有相同的效果。
#2
0
The environment variables are added to the shell you just opened. They only live as long as the shell lives.
环境变量将添加到刚刚打开的shell中。只有贝壳生存,它们才会存在。
If you want them to be persistent you have to make sure they are loaded every time. As someone else answered, add those lines to your ~/.bashrc
如果你想要它们是持久的,你必须确保它们每次都被加载。当其他人回答时,将这些行添加到〜/ .bashrc中
#1
0
You could add them to your .bashrc file in your home directory.
您可以将它们添加到主目录中的.bashrc文件中。
gedit ~/.bashrc
Add the lines you need at the end of the file, exactly as you were entering them before. The file is executed every time you open a new terminal. It will have the same effect as manually entering the commands every time you open a new shell.
在文件末尾添加所需的行,与之前输入的行完全相同。每次打开新终端时都会执行该文件。它与每次打开新shell时手动输入命令具有相同的效果。
#2
0
The environment variables are added to the shell you just opened. They only live as long as the shell lives.
环境变量将添加到刚刚打开的shell中。只有贝壳生存,它们才会存在。
If you want them to be persistent you have to make sure they are loaded every time. As someone else answered, add those lines to your ~/.bashrc
如果你想要它们是持久的,你必须确保它们每次都被加载。当其他人回答时,将这些行添加到〜/ .bashrc中