I've checked this answer first:
My question still is:
If I put these lines to my ~.zshrc file :
JAVA_HOME="/user/lib/jvm/java-7-openjdk-amd64"
export JAVA_HOME
alias sudo="sudo env JAVA_HOME=$JAVA_HOME"
Then do logout.
Then try :
> sudo ./somejava-stuff.sh
I still see "The JAVA_HOME environment variable is not defined"
When I check whether my alias was applied:
> which sudo
I got unexpected output that says:
"sudo: aliased to nocorrect sudo"
Q: Why it is so?
If I do this manually:
> sudo env JAVA_HOME=$JAVA_HOME ./somejava-stuff.sh
It works fine.
-- Also I tried to set "alias with the space" as was suggested here
I tired also this:
...
alias sudo='nocorrect sudo'
alias sudo="sudo env JAVA_HOME=$JAVA_HOME "
Like was suggested here.