I made my gitrepository and committed it. Inserted one java-file and wanted to to compile it ,but it gave me this:
Bernard@BERNARD-PC /c/users/bernard/desktop/git2 (master)
$ javac TestGUI.java
sh.exe": javac: command not found
It used to work in school on their computer,but at home on my laptop I cant make it work.
EDIT : I added javac as environment variable:
EDIT : Short term solution for the duration of the runtime of gitbash enter:
 `export PATH=$PATH:"/C/Program Files/Java/jdk1.7.0_21/bin/"`
Long term solution so you can reuse this command after shutting down and rebooting gitbash: (for win7) Create a file called .bashrc under Users/username. Open with notepad and add 'export PATH=$PATH:"/C/Program Files/Java/jdk1.7.0_21/bin/"' Finished
You need to add javac parent folder to your PATH.
export PATH=$PATH:"/C/Program Files/Java/jdk1.7.0_21/bin/"
You can check what PATH your git bash shell does see (probably the default one).
As suggested by @VonC in a comment in the correct answer in order to have this this command permanently added to the path you have to:
- Go to 
C:\Users\YourUsername - Open with an editor the file 
.bashrc(if is not there just create it) - Write the command to add the command to your path in this file: 
export PATH=$PATH:"/C/Program Files/Java/jdk1.7.0_21/bin/"
 - Restart GitBash and it works
 
The other answers did not work for me. What DID work (Windows 10) was:
- Go to System Properties -> Advanced -> Environment Variables
 - New System Variable
 - 'Variable name': PATH
 - 'Variable value': C\Program Files\Java\jdk-9\bin (or whatever your path is)
 - Restart Git Bash
 
来源:https://stackoverflow.com/questions/22281436/how-can-i-make-gitbash-find-the-javac-command