As far as I can see there are two issues in your question.
First, the question of the classifier: learn a classifier to detect cars. This is typical image classification. I suppose you're dealing with supervised learning. What you might want to do is something like, given you training database: resize all your images, extract features from them - look for Sift features e.g. -, and learn a classifier - (kernerl) SVM, Logistic Regression, ...
On the other hand, you have a second issue which is: given a picture, is there a car inside. For this, you have to slide you image - sliding windows with different sizes -, resize those patches to match the input of your classifier, run the feature extraction on them and then classify them.
This is a very naive pipeline but it should get the work done pretty easily and fast. You can go much farther - especially for feature extraction! The fact that your cars can be rotated, of different sizes etc. should be dealt with the feature extraction (Sift is designed for those issues).
As for some java implementation, you will find implementations easily with the key words above on Google, I'm not afraid about this =) This library is quite good I think: http://java-ml.sourceforge.net/ but I would rather recommend if you can to use http://scikit-learn.org/stable/ on Python which is really a great machine learning library! (along with openCV, https://opencv-python-tutroals.readthedocs.org/en/latest/, for Sift extraction)