Setting CLASSPATH permanently

陌路散爱 提交于 2019-12-01 10:30:16

问题


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

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?


回答1:


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.

You can also export the variable from ~/.bash_profile file, which will be loaded for login shells.




回答2:


for bash, add the following lines to this file (~/.bashrc):

PATH=[your path]:$PATH export PATH

for more details check PATH and CLASSPATH




回答3:


  1. Type nano .bashrc 2.Go to the end of line and type ->export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar(It is the location where you have stored .jar file that you have downloaded). 3.It becomes permanent now


来源:https://stackoverflow.com/questions/21078845/setting-classpath-permanently

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!