Java and Open-Tamil : Write Tamil Applications using Java

Java and Open-Tamil : Write Tamil Applications using Java

I’m sharing a small example; you can download (from Github) the whole Java package and include it in your desktop, mobile or web app. For Free! Example gist follows.

// include the sources for the com/tamil package from
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import com.tamil.utf8;
import com.tamil.Numeral;
public class utf8Demo {
public static void main(String [] args) {
/* Example 1: Get length of a Tamil word */
String inputWord = "எழில்",inputWord2 = "கட்டளை";
HashMap<String,Object> actual = utf8.get_length(inputWord);
System.out.println("Length of word "+ inputWord+ "= "+ actual.get("length") );
/* Example 2: Get number of Tamil letters */
//List<String> expected = Arrays.asList(new String [] {"எ","ழி","ல்"} );
StringBuffer actual = new StringBuffer();
for(String t : utf8.get_letters(inputWord)) {
actual.append( t );
if ( actual.toString() != inputWord)
throw new Exception("this will never happen because open-tamil parsed the words for you!");
/* Example 3: Convert number to a numeral */
double number = 1011.0;
/// you should see String numeral = "ஓர் ஆயிரத்தி பதினொன்று";
System.out.println("running -> "+number);
String numeral = Numeral.num2tamilstr(number).getNumeral();

view raw
hosted with ❤ by GitHub

open-tamil – Java usage

Open-Tamil for Java

A simple package containing 2-3 functions for Tamil text processing, is proposed for Java. It is available from open-tamil project repository, using the MIT license.

Using this project you can get utf8.get_letters, utf8.get_length API in Java. This code is, as always, tested using JUint.

Building Jar file from sources

Before you start you need the following,

  1. Download the source of open-tamil from github using the link
  2. cd open-tamil/java/OpenTamil
  3. Open this directory in your ‘Eclipse’ or ‘NetBeans’ IDE, and setup a library project
  4. Build the ‘JAR’ file
  5. Close open-tamil project
  6. On command line copy the jar file into your project (this is not open-tamil) directory
  7. You can being using the jar file like the following example, and as long as the JAR file is on your path, it should compile and run just fine.


        import com.opentamil.tamil.*;
        public class Petti {
            public static void main() {
                List<String> chars = utf8.get_letters("கட்டளை"); //strange fruit
                System.out.print("கட்டளை -> "+chars.size());

You should see an output like,
       கட்டளை -> 4