I was using Bash as my default shell on macOS but I decided to switch to Fish.

I am trying to switch between different versions of Java. In bash it was done using the `~/.bash_profile` 

```
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`

```

I have set the equivalent on Fish `~/.config/fish/fish_variables`

```
set -x JAVA_HOME `/usr/libexec/java_home -v 1.7`

```

Unfortunately, Java version is not being changed. How can I set environment variables (specific version of Java, in particular) using `~/.config/fish/fish_variables`?

### UPDATE:

According to the [FAQ](https://fishshell.com/docs/2.2/faq.html), instead of `~/.config/fish/fish_variables`, `~/.config/fish/config.fish` should be used. Also I created `~/.config/fish/fish.config` instead of `~/.config/fish/config.fish`.
['https://superuser.com/questions/1401673', 'https://superuser.com', 'https://superuser.com/users/806634/']
While I am not deeply familiar with [Fish](https://fishshell.com), based on what I am reading it seems like the issue is with the backticks in your command:

```
/usr/libexec/java_home -v 1.7

```

You see that is just like this in Bash:

```
$(/usr/libexec/java_home -v 1.7)

```

Keep that in mind and look at [this Fish FAQ entry](https://fishshell.com/docs/current/faq.html#faq-subcommand):

> 
> ### How do I run a subcommand? The backtick doesn't work!
> 
> 
> fish uses parentheses for subcommands. For example:
> 
> 
> 
> ```
> for i in (ls)
>     echo $i
> end
> 
> ```
> 
> 

Knowing that the config line should most likely be:

```
set -x JAVA_HOME (/usr/libexec/java_home -v 1.7)

```
```
function javaenv
   if test (count $argv) -eq 0
       /usr/libexec/java_home -V
   else
       switch $argv[1]
       case 'ls'
           /usr/libexec/java_home -V
       case 'set'
           set -xU JAVA_HOME (/usr/libexec/java_home -v $argv[2])
       end
   end
end

```

Can put the function above in ~/.config/fish/functions and use it to get the java\_home contents with

```
javaenv

```

and set the contents of java\_home with

```
javaenv set 1.8

```

Idea and contents taken from [here](https://medium.com/@axross/simple-javaenv-with-fish-shell-287ba4a84ba9)