Abhimanyu Singh
Abhimanyu Singh

Reputation: 11

setting classpath using setenv.sh for a project

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.

Upvotes: 1

Views: 2069

Answers (2)

Heath Lilley
Heath Lilley

Reputation: 383

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

Upvotes: 1

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.

Upvotes: 0

Related Questions