e-Zest members share technology ideas to foster digital transformation.

Local languages in Java

Written by Yuvraj Patil | Dec 17, 2012 3:16:46 PM

We can code Java in English as well as in many other languages like Marathi, Hindi etc. In order to make Java code readable in another language we have to change our program’s encoding to “UTF-8 Encoding”.

public class AnyLanguageUser {
    public static void main(String []yuvraj_patil){
        int त्रिज्या = 20;
	int व्यास = 2 * त्रिज्या;
	System.out.println(व्यास);
    }
};

  • Using IDE (Eclipse)
  1. Write this program in Java Project of Eclipse.
  2. While saving the program, save it’s encoding as “UTF-8 Encoding”.
  3. Run as usual, it will print 40.

  • Using notepad and CMD prompt
    1. Write the above program in a java file and name that file as “AnyLanguageUser.java”
    2. While saving the program save it’s encoding as “UTF-8 Encoding”.
    3. Open the CMD prompt and compile it as below
    4. javac –encoding UTF-8 AnyLanguageUser.java
    5. Run it as below using the CMD prompt
    6. java AnyLanguageUser

    Similarly we can write method names in local languages in the following way

    public class AnyLanguageUser {
        public static void main(String []yuvraj_patil){
            int लांबी = 20;
    	int रुंदी = 10;
    	int क्षेत्रफळ = त्रिकोणाचेक्षेत्रफळमोजणे(लांबी , रुंदी ) ;
    	System.out.println(क्षेत्रफळ) ;
        }
    
        public static int त्रिकोणाचेक्षेत्रफळमोजणे (int लांबी,int रुंदी ){
    	int क्षेत्रफळ = लांबी * रुंदी ;
    	return क्षेत्रफळ;
        }
    };