javac command not found in Git Bash
Solution 1
You need to add export PATH
command to .bashrc for Git Bash. Refer to this
Git for Windows: .bashrc or equivalent config files for Git Bash shell
Edit: Adding code
copy > ~/.bashrc
Add the following line to the file:
export PATH=$PATH:"/c/Program Files/Java/jdk1.8.0_45/bin/"
Save the file. Restart Git Bash. Tada
Solution 2
Try physically adding that path to the system environment variables from the control panel.
Search for 'system environment variables' --> go into Environment Variables --> look for [Path] from System Variables --> Click to highlight [Path] and hit Edit.
Depending on your computer, you might see a list of paths added, or a long string of paths separated by semi-colons. Copy and paste your java bin location.
MJW
Updated on November 28, 2022Comments
-
MJW over 1 year
I'm using Windows and Git Bash. Whenever I type a
javac
command in Git Bash, it comes back reading:sh.exe":javac: command not found
.I then have to type out
export PATH=$PATH:"/c/Program Files/Java/jdk1.8.0_45/bin/"
Thejavac
command then works on the next line after I type the export PATH command in.My question is, how do I get Git Bash to remember that export command so I don't have to type it out each time?
-
Nick Volynkin almost 9 years[off-topic] I recommend you to try cygwin.com as a command line tool. It's a NIX-shell tool for Windows.
-
-
sanjsanj over 5 yearsOn the current latest version of Windows10 the .bashrc file needs to be named .bash_profile