There is no railway connection between Croatia and Montenegro. You have to take the bus on the route from Split and Dubrovnik along the Adriatic coast to Montenegro with destination Kotor, Bar and Podgorica. The journey time from Dubrovnik to Bar by bus is about 3,5 hours.