You always have to lock on with the javelin however you can also lock onto any location of your choice apart from just vehichles. So basicly if you know that an enemy is in a building far away, you can lock your javelin on that building and its gonna clear that builiding out of enemies.
If i answered your question, click the 'thanks' button