Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not setting a version on mac #212

Closed
ror6ax opened this issue Aug 30, 2018 · 34 comments
Closed

not setting a version on mac #212

ror6ax opened this issue Aug 30, 2018 · 34 comments

Comments

@ror6ax
Copy link

ror6ax commented Aug 30, 2018

# 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?

@anton-fomin
Copy link

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

jenv enable-plugin export

@ror6ax
Copy link
Author

ror6ax commented Sep 13, 2018

@anton-fomin I get jenv: no such command enable-plugin'` :(

@saxtell-cb
Copy link

saxtell-cb commented Oct 18, 2018

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

@joshtrotter
Copy link

I have the same issue - OSX 10.13.6

@gcuisinier
Copy link
Collaborator

Can you provide the output of
jenv doctorplease ?

@saxtell-cb
Copy link

Can you provide the output of
jenv doctorplease ?

@gcuisinier, I've added the output to my original comment above ^^.

@gcuisinier
Copy link
Collaborator

@saxtell-cb Thank.

And jenv version ? :)

@saxtell-cb
Copy link

saxtell-cb commented Dec 11, 2018

~ » jenv --version
jenv 0.4.4

@gcuisinier
Copy link
Collaborator

heu .. that's not jenv version.
Java version maybe? :p

@gcuisinier
Copy link
Collaborator

jenv --version

@saxtell-cb
Copy link

Updated ^^

@gcuisinier
Copy link
Collaborator

gcuisinier commented Dec 11, 2018

Very strange ...

Can you give me the output of :
which jenv
jenv root
env | grep JENV

@saxtell-cb
Copy link

saxtell-cb commented Dec 11, 2018

~ » which jenv                                                                                
/usr/local/bin/jenv
------------------------------------------------------------
~ » jenv root                                                                                 
/Users/username/.jenv
------------------------------------------------------------
~ » `env | grep JENV`                                                                         
------------------------------------------------------------

That last command returned nothing.

@gcuisinier
Copy link
Collaborator

ok !

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

eval "$(jenv init -)"

@saxtell-cb
Copy link

Only in my .bash_profile

@gcuisinier
Copy link
Collaborator

and echo $JENV_LOADED?

@saxtell-cb
Copy link

Returns a blank line.

@gcuisinier
Copy link
Collaborator

And just to be sure, you are using bash ?

echo $SHELL

@saxtell-cb
Copy link

saxtell-cb commented Dec 11, 2018

~ » echo $SHELL                                                                              
/bin/zsh

@gcuisinier
Copy link
Collaborator

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

@saxtell-cb
Copy link

Seems like that was the problem. It's switching between versions nicely for me. Thanks @gcuisinier!

@saxtell-cb
Copy link

Except that jenv local <version> changes the version globally and not just in the local directory.

@saxtell-cb
Copy link

Never mind, I take that back. It is actually working. I just hadn't sourced in the other tmux pane yet. It's all working now! Thanks again @gcuisinier.

@doctorpangloss
Copy link
Contributor

doctorpangloss commented Jan 20, 2019

@saxtell-cb @ror6ax

I've written pretty clear instructions for macOS on my maintained fork:

https://github.com/hiddenswitch/jenv

This includes installing a special plist file for macOS GUI environment variables.

@mojitoming
Copy link

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~

@gosk8
Copy link

gosk8 commented Mar 27, 2019

Same issue too. it seems jenv global does not working well

@namithc
Copy link

namithc commented Aug 24, 2019

Thanks guys, I had the same problem and it worked with the below statements
eval "$(jenv init -)"
env enable-plugin export

@mapayares
Copy link

@namithc the command :
eval "$(jenv init -)"
worked for me. Do you know how I can make this command run every single time i open up a new shell? I tried adding it to the .bash_profile with no luck

@DhillonParwinder
Copy link

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

@doctorpangloss
Copy link
Contributor

As a previous user of jenv I've migrated to sdkman and no longer have any issues.

@imesh94
Copy link

imesh94 commented Sep 4, 2020

mine got fixed by adding eval "$(jenv init -)" to .zshrc

@nezed
Copy link

nezed commented Sep 18, 2020

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

@amrulfraroqui
Copy link

for me it worked after removing .java-version file available under /Users/{user}

@andrewflbarnes
Copy link
Contributor

This shhould all be well documented in the readme now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests