简体   繁体   中英

Linux export command not working

I have created a shell script in linux which uses export commands to set paths and classpath. But paths and classpath are not getting set correctly as shown below. Below is the part of script

Input:

export JAVA_HOME=/usr/java/latest

export CLASSPATH=$JAVA_HOME/lib

echo $CLASSPATH

Output

/lib/java/latest.

It should be /usr/java/latest/lib. Please can someone tell me where I'm wrong or why it is returning wrong output.

You need to source the script where you are setting the variables

source your_script_name

Or another way of sourcing is by executing your script as follows:

. ./your_script_name

Make sure there is space in between 2 dots

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM