Why Is Git Bash Not Using the Correct Java Path as Defined in the Path Environment Variable

echo %JAVA_HOME% works in cmd, but not in git bash

Turns out, git uses a completely different syntax to do echo.

I had been doing echo %JAVA_HOME% when I should have been doing echo $JAVA_HOME.

I couldn't see that I was supposed to be using $ and not % sign because the symbols looked so similar in my font. I only found out after copy/pasting an answer out of frustration into bash and having it magically work when it hadn't worked prior.

But yes, the answer is to use $ and not % because they mean completely different things. Git bash uses $, command prompt uses %. You'd think they'd just use the same symbol to get the job done.

Git-bash do not uses my enviroment variables for maven installation

Put the following into a file named .bash_profile into your home folder (like you would on a UNIX system):

export M3_HOME=/c/ECG/Maven/mavenCurrent
export JAVA_HOME=/c/ECG/Java/jdk8/jre
PATH=$JAVA_HOME/bin:$PATH

You may also want to add more environmental variables and path entries this way, depending on what you need to run your system.

Why can't Git Follow my Java JDK installation path?

Are you sure you need to set the actual JAVA_HOME variable? If I remember correctly, for git bash it looks at the $PATH variable for the java version. Maybe try appending your java location here.

also, to double check (sorry if you already know this), you can run the env command to list all your environment variables.

$ env  

Try setting the path and run the java -v command to verify the installation is correct. If not, what is the exact error?

$ java -v

Edit
Some more info, to set the $PATH in git windows I think you have to update your $HOME. See this or some other posts (google) for an explanation

Git for Windows: .bashrc or equivalent config files for Git Bash shell

Set an environment variable in git bash

A normal variable is set by simply assigning it a value; note that no whitespace is allowed around the =:

HOME=c

An environment variable is a regular variable that has been marked for export to the environment.

export HOME
HOME=c

You can combine the assignment with the export statement.

export HOME=c

Extend $PATH variable in git bash under Windows

Here are two ideas.

You can have your path with double quote mark.

export PATH=$PATH:"/C/Program Files (x86)/apache-maven-3.3.3/bin"

enter image description here

Or, You can also make symbolic link for the directory.

ln -s "/C/Program Files (x86)/apache-maven-3.3.3/bin" ./mvnbin

export PATH=$PATH:/your-path/mvnbin

enter image description here

It works for me in mingw32 environment.

BeanUtils copyProperties API to ignore null and specific propertie

If you want to ignore null-value you have to do it with the following line of code before copying properties:

BeanUtilsBean.getInstance().getConvertUtils().register(false, false, 0);


Related Topics



Leave a reply



Submit