永久设置CLASSPATH [英] Setting CLASSPATH permanently
问题描述
为了设置我的classpath环境变量,我正在运行以下命令:
In order to set my classpath environment variable, I'm running the following command:
export CLASSPATH=/path/to/appropriate/dir
为了检查这是否正确设置,我将输入
In order to check that this was correctly set, I'll type
echo $CLASSPATH
并返回/ path / to / proper / dir。
and am returned /path/to/appropriate/dir.
然而,当我在终端中打开一个新的标签或窗口时
However, when I open up a new tab or window in the terminal
echo $CLASSPATH
什么都不返回。这里发生了什么?
returns nothing. What's going on here?
推荐答案
您在终端中设置的变量仅对该终端有效。你应该做的是,在你的〜/ .bashrc
文件中导出变量,该文件是为每个终端加载的。所以,在 .bashrc
文件中添加该语句,你就没事了。
The variable you set in a terminal, is valid only for that terminal. What you should do is, export the variable in your ~/.bashrc
file, which is loaded for each terminal. So, add that statement in the .bashrc
file, and you'll be fine.
你也可以导出来自〜/ .bash_profile
文件的变量,将为登录shell加载。
You can also export the variable from ~/.bash_profile
file, which will be loaded for login shells.
这篇关于永久设置CLASSPATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!