SourceForge has been redesigned. Learn more.

Using transliteration

Joyce Babu
  • Joyce Babu

    Joyce Babu - 2005-06-18

    Is it possible to pass the inputs by users to another program before outputting it on the other user's windows? What I want to do is pass the input to another program which transliterates the input and returns an out put. It is this output that I want to display to the users. Is it possible? Any help is welcome.
    Thanks in advance


    • Daniel Tahin

      Daniel Tahin - 2005-06-20


      Yes i guess this is realizable, but you should modify the code a bit. If a user types something in a chatroom or private chatroom you can observe this in 2 location: directly in the chatroom-GUI (, -in the awt-version-)  or  in the (this one creates the commands, they could be sent directly to the NFC-server).
      I prefer to modify the, because this is global for all GUI-things. I made the same, allowing the client to send text, they contains newline, or tab signs.
      I put for you some System.out.println(); into these files, showing the place to modify. In you will see only 4 methods, they have the println(); code. All other functions in this file make ping, whois, ... messages.
      Ah, you can find these codes:

      Let me know, if something goes wrong...

    • Joyce Babu

      Joyce Babu - 2005-06-23

      Sorry for being late. And thank you very much for you reply and code. I am a newbie to java. I have been trying to understand the code all these time. But unfortunately I couldn't make out anything. My problem is how to send the input to the program. In perl and php I use the command

      $cmd = "print -n \"$inputText\" | $program";
      $outputText = `$cmd`;
      (I am using linux)

      where $program is the program, $inputText is the input and $outputText is the transliterated output.
      Can you plz tell me how to do this in java.
      Also am I allowed to use the code for free?


    • Daniel Tahin

      Daniel Tahin - 2005-06-24


      It seems, sending/receiving the text over sockets would be the easiest way. In Linux there is the pipe mechanism to communicate between 2 programs, but i think this doesn't work in Java (?).
      If you can implement some socket communication, i can help to implement the same in NFC.
      What language are you using for your program?

      > Also am I allowed to use the code for free?
      Yes of course, but without violating the GNU/GPL license:-)


    • Joyce Babu

      Joyce Babu - 2005-06-27

      My program is in c++.
      I heard that Java can be used to communicate with cgi. I know how to use the transliteration program via cgi. Infact I was thinking this was the only possiblity. You had asked me whether I can implement socket communication. Sorry I have no idea on what it is. Can you plz tell me whether my hosting service need to provide that facility or not? Or is it possible without any other extra facilities?


    • Daniel Tahin

      Daniel Tahin - 2005-06-30


      Sorry for my delay. I didn't forget you :-). I've created a small demo programm to test, whether the communication with the cgi works.
      First some words about sockets. This one doesn't need any other programm (you can execute cgi mostly with a http server). So plain sockets are faster. You can try this by giving "telnet 7777" and type /help.
      But if you behind a proxy or a firewall, you can only connect to a limited range of ports(/sockets). So using the same telnet-command, like above, will perhaps fail. But http (port 80) is generally allowed. This means, if you create a servlet, or cgi, you can send any data to it. This is allowed, because servlet/cgi is running together with a http-server. And of course the servlet will pass any data to the other server, that you can't reach, if you behind a proxy.
      I thought your transliteration programm is running on the same machine. In this case, there isn't a big need for a cgi-java communication, but it will work as well...

      Ok. Back to the demo-programm. It will send the data to a cgi using the POST-method. Sorry, i couldn't test it with a cgi (i don't have any), only with the NFC-servlet. If you type java ComCgi  "",  it will send a query after 4 sec, and you will receive the message "You do not exist.  Go away."  from NFC.

      Some note: before i send anything to the cgi, it will be encoded using encode(), and for this i set some properties with setRequestProperty()
      Reading the response of the cgi is done by readLine() (so the response should be terminated by a '\n' or '\r').
      The source and the compiled code is on my hp...

      Hope everything will work fine:-))

    • Joyce Babu

      Joyce Babu - 2005-07-02

      EUREKA!!!!!Yes, it worked. I tested the program with CGI and could establish a two  way communication. THANK YOU VERY MUCH.

      Can you tell me how to implement the code in NFC. Is it possible to do it with the following code or do I have to include the class file separely while compiling?

      //import commands
      public class CommandMakerLocal implements ICommands {
          public static final String constructSayToUserMessage(String user, String msg) {
              String tmp = SAY_TO_USER + DELIMITER + user + DELIMITER + msg;
              System.out.println("sayToUser: "+tmp);
              return send_and_receive(tmp);
          private void send_and_receive(String message) {
          //code for the function


      But the biggest problem is that still I am not able to compile NFC. I am using JDK 1.3.0. and the latest version of ant on windows. When compiling I am getting 7 errors( Would you plz tell me what to do?


    • Daniel Tahin

      Daniel Tahin - 2005-07-04

      Hi Joyce!

      Nice to hear, that's worked :-)
      Yes you can put only the code of send_and_receive() in, but i don't recommend you. I've studied the code, and if you modify only the CommandmakerLocal class, you can't see the effect of the translieration program on your side, because CommandMakerLocal creates messages, that will be sent over the net. So only the other users will see it...
      I put send_and_receive() in, and modified the classes, that handle the emote/sayto commands. The only thing you should do is to modify the variable _url in (at the beginning), to use your cgi.
      Hopefully a response from the cgi won't take a lot's of time, because until there isn't any response, the nfc-client can't receive messages from the internet...

      To compile it, you must update to jdk1.4, because the classes, listed in the error-file, are in 1.4 and above.

      Have fun!
      PS: can i get your CGI? :-)

    • Daniel Tahin

      Daniel Tahin - 2005-07-08


      Did you succeed your work?
      There is a thing, i forgotten to mention. If you ever plan to use the transliteration-program on a different machine, NFC-client was downloaded from, you can get an error, and probably you won't be able to make use of it!
      This can especially happen, if you use the client-applet (not the standalone version). This is due to the restrictions of an applet. By default an applet can connect only to the server, it was downloaded from.
      So if you want to use the CGI, you must grant some extra permission to the applet!

      Have fun!


Log in to post a comment.