1

I want to write an sh file that will set classpath in Linux.

I tried using:

export ClASSPATH=$CLASSPATH:$ABC_HOME

However, when I run the .sh file it doesn't set the classpath.

john_science
  • 6,325
  • 6
  • 43
  • 60

2 Answers2

1

Executing the bash script only sets the environment for the child process. The "source" command may do what you want...

https://askubuntu.com/questions/53177/bash-script-to-set-environment-variables-not-working

Community
  • 1
  • 1
Heath Lilley
  • 393
  • 1
  • 6
  • 11
0

You should make it a shell function, or source it. Because the environment variables are local to the shell (the one started by invoking your shell script).

Please read the advanced bash scripting guide. See also this answer to a similar question.

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547