Unless A.java contains private data that cannot exist in the repo history, you should commit a deletion of the file, not try to remove its previous existence.
git rm A.java
If the file contains sensitive data which must be removed, it is possible to remove the history of the file, but it will rewrite refs, require a forced push, and require extra work on the part of anyone who has cloned or pulled your current refs.
https://help.github.com/articles/remove-sensitive-data
In short:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch A.java' --prune-empty --tag-name-filter cat -- --all
Edit to incorporate answer if trying to restore a version from another repo or branch:
If A.java is a file that you've modified, and you wish to return it to the original version that is available at upstream/master
then this will replace your current copy:
git checkout upstream/master A.java