How do you set the java version to use in a windows git bash? Does it work via the environment variables? Java -version gives another version in dos command prompt than in git bash...
Let's say you want to try other Java versions but you don't want to alter the Windows environment variables.
Steps:
Edit the .bashrc file and add the following code below.
#For example:
export JAVA_HOME='/c/Program Files (x86)/Java/jdk1.8.0_45'
export PATH=$JAVA_HOME/bin:$PATH
.bashrc and .bash_profile are files created during the git-bash installation.
You don't set the java version. You are seeking the $PATH
(bash) and the %PATH%
(Windows/DOS/cmd.exe) environment variables. When you run the command java -version
, the shell searches the directories on the $PATH
to locate the java
program and run it with the given arguments. If you get different results in different shells then that means you have different PATHs such that a different installation of Java is found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With