I have two versions of Java installed on my system - some programs require Java 7, some require Java 8.
Java 8 is my default system, so when I executed the Java 7 commands, I used:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.*.jdk/Contents/Home/ \
java_7_program
I want to set an alias to write instead
j7 java_7_program
I defined:
alias j7='JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.*.jdk/Contents/Home/'
But then the launch j7 java -version
calls:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
the man page (search for "Aliases") states that this is done as a direct substitution. Is there a reason why this does not work?
bash --version
prints GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin14.5.0)
A more isolated example (minus java):
$ alias foo='BAR=baz'
$ type foo
foo is aliased to `BAR=baz'
$ foo echo $BAR
[blank line]
source
share