How long did a train ride take from Lithuania to Germany in late 19th century?

2 hours. However, that would not have taken you very far into Germany.

Lithuania and Germany (Ostrpreussen) bordered each other in the 19th century, so depending where you were in Lithuania - it could take as little as 5 minutes.

The district of Klaipeda (previously Memel) in Lithuania was part of Germany in the 19th century, as was the area round Tilsit.