How to auto detect the current system language?

3
package linguagem;
import java.util.*;
public class Linguagem {
    public static void main(String[] args) {
        Locale locale = new Locale("PORTUGUESE", "PT");
        System.out.println("Linguagem: " + locale.getDisplayLanguage());
    }
}

Then it returns portuguese .

However,mysystemisinEnglish,Ineedittoreturnenglish.

Is there any way to auto detect the current system language?

    
asked by anonymous 13.06.2018 / 11:00

1 answer

4

You can use Locale.getDefault();

From the documentation:

  

... The Java Virtual Machine sets the default locale   during startup based on the host environment ....

In free translation:

  

The Java virtual machine gets the configuration of the boot location based on the system configuration.

    
13.06.2018 / 11:12