How do you set java version in windows git bash?

Let’s say you want to try other Java versions but you don’t want to alter the Windows environment variables.

Steps:

  • Go to your home folder. i.e. C:\Users\MyAccountName
  • 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.

Leave a Comment

tech