cscan
cscan

Reputation: 3840

Setting CLASSPATH permanently

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?

Upvotes: 1

Views: 6528

Answers (4)

Giacomo
Giacomo

Reputation: 19

After you set the CLASSPATH variable in you ~/.bashrc file remember to enter source ~/.bashrc in the terminal.

Upvotes: 0

Prashant Sinha
Prashant Sinha

Reputation: 1

  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

Upvotes: 0

Ammar Mohammed
Ammar Mohammed

Reputation: 277

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

PATH=[your path]:$PATH export PATH

for more details check PATH and CLASSPATH

Upvotes: 0

Rohit Jain
Rohit Jain

Reputation: 213193

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.

Upvotes: 3

Related Questions