Yes, Java can be used for machine learning. There are a number of machine-learning libraries available for Java:
Apache Mahout
TensorFlow
Scikit-learn
JML