jenv: not setting a version on mac

# g.reshetniak @ MP24502 in ~/edge on git:master x [11:24:27]
$ jenv versions
  system
* 1.7 (set by /Users/g.reshetniak/edge/.java-version)
  1.7.0.181
  1.8
  1.8.0.181
  openjdk64-1.7.0.181
  oracle64-1.8.0.181

# g.reshetniak @ MP24502 in ~/edge on git:master x [11:24:33]
$ jenv global 1.7

# g.reshetniak @ MP24502 in ~/edge on git:master x [11:24:50]
$ java --version
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

# g.reshetniak @ MP24502 in ~/edge on git:master x [11:24:53]
$ jenv local 1.7

# g.reshetniak @ MP24502 in ~/edge on git:master x [11:26:31]
$ java --version
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

Seems like basic functionality, but it does not work as expected for me. What am I doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 34 (3 by maintainers)

Most upvoted comments

Same issue. I used the following commands.

➜  ~ jenv global oracle64-1.8.0.202
➜  ~ jenv versions
  system
  oracle64-1.7.0.80
* oracle64-1.8.0.131 (set by /Users/xxxx/.java-version)
  oracle64-1.8.0.202

The outcome was not what I expected. Then~

➜  ~ jenv version
oracle64-1.8.0.131 (set by /Users/xxxx/.java-version)

I found a file named .java-version in the user’s directory. So I removed it. Then I got what I wanted~

I had the same problem, I could workaround it by enabling export plugin

jenv enable-plugin export

Ok, that’s probably the problem.

zsh is using .zshrc and not .bashrc So jenv init is not called.

echo 'eval "$(jenv init -)"' >> ~/.zshrc

And restart you shell, and try again please

I’m having the same issue as @anton-fomin above. Any resolutions yet?

~ » jenv doctor
[OK] No JAVA_HOME set [OK] Java binaries in path are jenv shims [OK] Jenv is correctly loaded

ok !

Do you have this lines in your .zshrc/.bashrc:

eval "$(jenv init -)"

After changing the version globally , and running java -version, the versions specified by jenv and the global java version differ. I fix it by using the command:

eval “$(jenv init -)” env enable-plugin export

Went into the same issue. Found that jenv doctor noticed about other java installation in $PATH which added by sdkman:

[OK]	JAVA_HOME variable probably set by jenv PROMPT
[ERROR]	Java binary in path is not in the jenv shims.
[ERROR]	Please check your path, or try using /path/to/java/home is not a valid path to java installation.
	PATH : /usr/local/Cellar/jenv/0.5.4/libexec/libexec:/Users/d.naumov/.sdkman/candidates/java/current/bin:/Users/d.naumov/.jenv/shims:/Users/d.naumov/.jenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
[OK]	Jenv is correctly loaded

In my case i don’t really need sdkman so i’ve decided to remove it (Remove lines with sdkman from your .zshrc/.bashrc/.bash_profile, and then rm -rf ~/.sdkman)

Putting all replies above together:

  1. Check is following lines

    • eval "$(jenv init -)"
    • and export PATH="$HOME/.jenv/bin:$PATH"

    presented in your .zshrc/.bashrc/.bash_profile (check files in same order)

  2. Run jenv doctor and check for reported issues

  3. Make sure that there is no any other java folder in your $PATH by running echo $PATH | tr ":" "\n"

  4. Try jenv enable-plugin export

@anton-fomin I get jenv: no such command enable-plugin’` 😦