How to compile and run java program in Hindi

We all know how to write Java programs. We also have used English language for doing this. Today, I tried to write a Java program in hindi language using eclipse and then execute it.

Java program in Hindi

Lets see how this can done. Below is code sample which can easily be written with any language translator.

package runtime;

public class DemoHindiProgram {
	public static void main(String... s) {
		java.util.Locale हिन्दी = new java.util.Locale("hi", "IN");
		int लंबाई = 20;
		int चौड़ाई = 10;
		int क्षेत्रफल;
		क्षेत्रफल = लंबाई * चौड़ाई;
		System.out.printf(हिन्दी, "%dn", क्षेत्रफल);

2. Problem

Actual problem starts with when you copy above code in eclipse plugin. As soon as you copy above code in eclipse, it start complaining through various compilation issues.

These issues are basically due to default character encoding in eclipse which is “Cp1252“.  We need to change this.

3. Solution – Change eclipse default encoding

This default encoding can be changed from location : "File > Properties". Change it to UTF-8.


Now create a class with name “”.

This file will have no compilation issues and if you will execute above program “Right click > Run as > Java program“, you will be able to see the output as “200” in console output.

Fun fact is that console output is also in Hindi letters.


Happy Learning !!

Leave a Reply

Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial