I'm confused. I want find JAVA_HOME value in server and type this code in bash script.
ssh username@server "echo ${JAVA_HOME}"
and try
ssh username@server "echo $JAVA_HOME"
or
ssh username@server 'echo $JAVA_HOME'
and all of they not worked;
I replace "JAVA_HOME" with "PATH" and it's work; I connect with ssh to server and try "echo $JAVA_HOME " and it's work. I think the problem is "_" and I don't know how fix it. please help me
Your approach is not feasible.
$JAVA_HOME will be interpreted to the variable value in localhost instead of the remote server. Besides, executing by ssh is not a login shell, you will not get environment variables defined in /etc/profile