Reputation: 16436
I just downloaded Java and according to the Java Control Panel the executable is at this directory:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Now I want to export an env variable JAVA_HOME
as such:
>export JAVA_HOME=“/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java”
But when I print out the variable everything after the space is butchered
>$JAVA_HOME
-bash: “/Library/Internet: No such file or directory
How do I properly export this path to the variable?
Now there is another question that answers this but that answer there doesn't work:
>SOME_PATH="/mnt/someProject/some path"
>$SOME_PATH
-bash: /mnt/someProject/some: No such file or directory
And using the other answer on there:
>SOME_PATH=/mnt/someProject/some\ path
>$SOME_PATH
-bash: /mnt/someProject/some: No such file or directory
And here is my bash version (I'm on macOS 10.14.5):
>echo $BASH_VERSION
3.2.57(1)-release
Upvotes: 2
Views: 6939
Reputation: 71
I think the quote mark you used (“) is not the ASCII quote mark (" or ').
Upvotes: 0
Reputation: 11959
You must use double quote or single quote: the interpreter is seeing “ as any character, thus trying to find a program “/Library/Internet
.
export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java'
You don't need to escape anything with single quote, apart from single quote and backslash.
Note that when you are using it directly, like $JAVA_HOME foobar.Main
, you need to add double quote as well because in that case $JAVA_HOME
contains space:
"$JAVA_HOME" foobar.Main
Some terminal might work without double quote, but you should not rely on it.
However, the JAVA_HOME
is wrong: it should point to a folder which contains /bin/java
:
export JAVA_HOME="/c/Program Files/Java/jdk1.8.0_202"
export PATH="$JAVA_HOME/bin:$PATH"
In that case, you would simply invoke java and your shell would resolve the executable.
Upvotes: 0
Reputation: 12110
Single quote and double quote , everything works:
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$ echo $BASH_VERSION
4.4.12(1)-release
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$ export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$ echo $JAVA_HOME
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$ export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java'
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$ echo $JAVA_HOME
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
[iahmad@web-prod-ijaz001 ~]$
[iahmad@web-prod-ijaz001 ~]$
Upvotes: 1