If it's a 4-5 journey by train, the tickets will cost you something about 300 EUR. (Less if you buy in advance the kind of ticket you can't return. But then you can't return the tickets and I've already had companies cancelling the day before the interview, so this doesn't sound like a viable option).
I would thank them for the information and write that in this case I need to withdraw my application.
Unless you have so much money / the job is so important to you that 300 EUR doesn't make you any difference. But honestly, in that case, I would invest in some better clothes/ changes in the look (dentist services, hairdresser...) or books/ resources/ courses to prepare, not a job interview at a company that doesn't respect candidates.
I had a situation like that in summer. It was a global leader, a huge company. They invited me and I was completely shocked to discover they don't cover train costs. After my withdrawal, they suggested a skype interview. We had it on the day I was to come to their headquarters. It resulted that the new employee was to report to two people who worked part-time (they had a shared position). The interview was with just one person, the other had a vacation and didn't even know about my existence. They also wanted to pay me much less than my salary expectations. Had I gone there I would have wasted 300 EUR and a day of PTO for a pointless interview.