Generally speaking, it is impossible to master a new language by only living in a foreign country. Before coming to a foreign country, it is necessary to learn the new language to some extent.
So, what is necessary to master a new language? Firstly, it is necessary to learn the knowledge of the new language such as grammar and vocabulary. Secondly, it is necessary to train how to use the knowledge.
Without saying, it costs much to study abroad. To save the cost as much as possible, it might be possible to learn grammar and vocabulary of a foreign language and train to use them in your home country. It is better to do what you can do in your home country before studying abroad.
Japanese is not the exception. It would become easier to master Japanese if you come to Japan after learning fundamental Japanese and training to use it in your home country. And then, you don't have to spend much time to master Japanese in japan and you can save costs of your study abroad eventually.