Passing Japanese characters to Java program

Hi,
I am using Java POI APIs for creating/modifying excel spreadsheets. The platform is Solaris. The data to be populated contains both English as well as Japanese characters. The input data to Java program comes from a perl program. When I populate the data in excel or even print using System.out.println, it prints ???... for Japanese characters. The data is in SJIS format.
I tried converting it to UNICODE in java but that doesn't seem to be working.
I also tried using native2ascii for converting the data to UNICODE before it is fed to Java program using the following command
native2ascii -encoding SJIS <Input File> <Output File>
Although it converts the charaters into UNICODE correctly in the form \u8a3c\u523... but when it is input to Java, the program prints the string as such.
But if this string is hardcoded in the program, the Japanese characters are printed correctly.
Could anybody please throw some light as to the data should actually be passed to the Java program.
Thanks

Sekhar
Ive realised the solution will probably involve HttpServletRequest.setCharacterEncoding.
Im now upgrading to Tomcat 4 because 3 didnt support this method. Once I'm through the upgrade, I'll try Japanese the chars again.
I would guess I need to force my web pages to utf-8 and use HttpServletRequest.setCharacterEncoding(utf-8) in the servlet to get it working ?

Similar Messages

  • How to pass arguments to a java program.

    I want to pass a file name to java program while it is going to execute.
    ex: c:\>java <.class> <filename>
    so that i have to take that filename into a string. Is it possible? If it is possible please help me.
    and how can i check whether the filename argument is given or not through command line argument?

    public class Program{
    public static void main(String[] args){
    filename = args[0];
    static String filename;
    this code is working. But if I did not give filename, and I only give like this
    java Program
    Then how can i now whether the argument (args[0]) is passed or not?

  • Can't use certain characters in java programs.

    For some reason I cannot use characters like: " ^ ~ | " in java programs.
    I can type them in a terminal and then paste them into the program, but cannot type them inside the java program - It's has been like that in every java application I have used. It only works when typing them in a applet running on a browser.
    Im running Linux RH 7.2 with JDK1.4.0 (It works fine in windows 2000)
    Hope somebody can help me.
    /Tommy

    Ehmm. What makes you believe that it isnt?
    I can't make exclusiveOr operations and if(bubba || bubba2) something....And that is a problem / annoyance.
    I can type every other characters but those ��� works fine as well.

  • Can't pass params in xsql java program

    I tried xsql java program in the xml dev guide.
    It seems that the program failed to recognize the params.
    Here is my code:
         Hashtable params = new Hashtable (3);
         params.put("docid", "801");
         params.put("orderby", "citeid");     
         params.put("xml-stylsheet", "none");
         req.process(params, new PrintWriter(System.out), new PrintWriter(System.err));
    I used the command line to run the xsql page with 2 params above, and it works fine.
    Does anyone know how to solve this problem?
    thanks,

    Ignore this post. Seems one package was in an 8.1.5 calling the xmldom packages in an 8.1.6 database. Problem fixed by moving calling package to the same database.

  • I need a tutor in order to pass my class in Java Programming!

    I'm having a lot of trouble keeping up in my online course. Because there is no class room, I find it difficult to ask questions. The time lap between question and answer makes it extra difficult to concentrate and stay focused on the problem. I would really like someone to be my tutor. Corresponde via email so that I can get help quicker and stay on track.
    I'm suppose to write an array in order to keep inventory. I have no idea where to even start. Here is the assignment, if you can help me and point me in the right direction, or show an example of codes I can use, it would be greatly appreciated.
    1) Create a product class that holds the item number, the name of the product, the number of unites in stock, and the price of each unit.
    Item # 1, Red Hanging Candle Holder, 24, $12.00
    Item # 2, Blue Hanging Candle Holder, 24, $12.00
    Item # 3, Green Hanging Candle Holder, 24, $12.00
    Item # 4, Yellow Hanging Candle Holder, 24, $12.00
    2) Create a Java application that displays the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit).

    God bless, Darryl. My time is more valuable to me.
    Maybe this arrangement works because you need the
    instruction as much as the OP does. The only
    question is: who will provide it? If neither person
    knows more than a month's worth of Java, how is new
    information brought in?
    Thanks duffymo for your blessing. As programming is just a hobby for me -- since 1983 -- I agree that my time is (much much) less valuable than yours. And yes, I expect the learning process to be mutually beneficial. And while I don't plan to make my living off java, I believe in doing things correctly or not at all. My one month experience in Java is backed up by programming in more languages than most professionals use in a lifetime, on platforms starting from pre-DOS systems with CTDs and a single-line display through DOS, xenix, PDP-11, MicroVAX and every version of Windows from 95 onwards.
    In any case, don't you think it would help if the simplest of questions were kept off these forums and solved in mutual self-help groups? some of whose members had nore time than others to spend on Googling and searching the forums? The first benefit would be to those who have progressed beyond the obvious, as you seniors would have more time to answer their pleas for help instead of getting bogged down in badly or unformatted code with all the trappings of cut-n-paste, meaningless comments that seem to be intended more for the teachers than the learners -- I could go on and on.
    I apologise for what I'm about to do; I do really agree with the general feeling on the forums that OPs benefit much more from being guided towards their goal than from being spoonfed a code that works. But I would really appreciate your critique of this code, which is my first console application. It took about half an hour, including Googling. I am aware that there are absolutely no comments, and the output columns don't line up, due to my as yet inadequate knowledge of output formatting. Anything else you can point out would help me in my learning process.
    Thanks for your time, Darryl
    File Inventory.javapublic class Inventory
        public static void main (String args [])
            int[] itemNumbers   = { 1,
                                    2,
                                    3,
                                    4
            String[] itemNames  = { "Red Hanging Candle Holder",
                                    "Blue Hanging Candle Holder",
                                    "Green Hanging Candle Holder",
                                    "Yellow Hanging Candle Holder"
            int[] unitsInStocks = { 24,
                                    24,
                                    24,
                                    24
            double[] unitPrices = { 12.0,
                                    12.0,
                                    12.0,
                                    12.0
            Product[] products = new Product[4];
            for ( int i = 0; i < products.length; i++)
                products[i] = new Product(itemNumbers,
    itemNames[i],
    unitsInStocks[i],
    unitPrices[i]);
    double productValue = 0.0;
    double totalValue = 0.0;
    System.out.println("Item #\t" +
    "Name\t" +
    "Units in stock\t" +
    "Unit price\t" +
    "Total Cost");
    for ( int i = 0; i < products.length; i++)
    productValue = products[i].get_productValue();
    totalValue = totalValue + productValue;
    System.out.println(products[i].get_productDetails() + "\t" +
    Double.toString(productValue));
    System.out.println("");
    System.out.println("\t" +
    "\t" +
    "\t" +
    "Grand Total\t" +
    Double.toString(totalValue));
    File Product.javapublic class Product {
        private int itemNumber;
        private String itemName;
        private int unitsInStock;
        private double unitPrice;
        private Product()
        public Product(int    itemNumberIn,
                       String itemNameIn,
                       int    unitsInStockIn,
                       double unitPriceIn)
            itemNumber   = itemNumberIn;
            itemName     = itemNameIn;
            unitsInStock = unitsInStockIn;
            unitPrice    = unitPriceIn;
        public double get_productValue()
            double unitValue = (double) unitsInStock * unitPrice;
            return unitValue;
        public String get_productDetails()
            String productDetails = Integer.toString(itemNumber) + "\t" +
                                    itemName + "\t" +
                                    Integer.toString(unitsInStock) + "\t" +
                                    Double.toString(unitPrice);
            return productDetails;
    }The forum software seems to have reduced my indentation by 1 space in many lines, they line up correctly in Notepad.
    Message was edited by:
    Darryl.Burke

  • How to read Korean characters using Java program?

    In Oracle table, i am having Korean characters, how to read those characters using JDBC and insert into SQL Server?
    NLS_NCHAR_CHARACTERSET is UTF8

    What data type is the column in the Oracle table? The NLS_NCHAR_CHARACTERSET would control the encoding of NCHAR and NVARCHAR2 columns. The NLS_CHARACTERSET would control the encoding of CHAR and VARCHAR2 columns.
    Justin

  • Printing unicode characters in Java - help

    Hi there,
    I want to print out unicode characters through java programming language in windows system. For example, I want to print Devanagari characters. I found out that '\u0900' to '\u0975' represent devanagari characters. So I tried following,
    out = new PrintStream(System.out, true, "UTF-8");
    out.println('\u0911');
    but they print characters like ��� and not the actual devanagari characters. Just to be more clear, devanagari script is used by Hindi, Nepali and similar languages.
    If you knew about it and could give any suggestions, that would be very helpful.
    Thanks in advance!

    priyankabhar wrote:
    I am not sure, it is just a windows system and I am trying to print to the command line. Please suggest me how I can find out if my console supports it.Use the CHCP command to find out what code page your console uses. And as already suggested, Google is a good resource if you don't know what a "code page" is.

  • How to read e-mail via java programming...

    String host= "myhostname";
    String user="myusername";
    String pass= "mypassword";
    Properties props =System.getProperties();
    Session session =Session.getInstance(props,null);
    Store store= session.getStore("imap");
    System.out.println(store);
    store.connect(host,user,pass)
    this is my java program. when i run this i am getting the following error... but i can able to send the mail.
    Exception in thread "main" javax.mail.MessagingException: Connection refused: connect;
    nested exception is:
         java.net.ConnectException: Connection refused: connect
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
         at javax.mail.Service.connect(Service.java:288)
         at javax.mail.Service.connect(Service.java:169)
         at com.ebay.trinity.tps.EmailClient.main(EmailClient.java:25)
    Caused by: java.net.ConnectException: Connection refused: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.SocksSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
         at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
         at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
         at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
         ... 3 more
    what could be the reason.. am i missing anything here. please help me..
    Thanks in advance
    Marimuthu.sp

    this is my java program. when i run this i am getting the following error... but i can able to send the mail.See this thread, its just about 2 days old:
    [http://forums.sun.com/thread.jspa?forumID=54&threadID=5349815]
    Specially see Reply#4
    Thanks!
    P.S.: Its a good practice to search the forum for the problem you are facing before posting, because there a 50% chances that others might also have faced similar problems before.

  • Passing Null Characters from Unix Shell Script to Java Program

    Hi Experts,
    Facing an issue with a shell script....
    The shell script has 10 input parameters....
    1st Parameter is a compiled Java program name(This can keep changing)
    Rest 9 are the parameters of the Java Program...
    The following piece of code is working when Test "a z" "b t" "" "" "" "" "" "" "" "" is hardcoded.
    lv_java_string=`java Test "a z" "b t" "" "" "" "" "" "" "" ""`
    The whole thing being dynamic.....
    But when I dynamically populate the same on to a parameter lv_java_param and then execute the same
    lv_java_string=`java $lv_java_param`
    if i echo $lv_java_param  its giving me Test "a z" "b t" "" "" "" "" "" "" "" ""  correctly
    Im facing some issue...... The issue is " is being treated as a parameter itself and the space between a and z is not taken into consideration and hence z is taken as the 2nd parameter
    Issue seems to be something like the precedence in which the above statement is executed, because of which "s are calculated/manipulated. Is it something like
    a) $lv_java_param is computed  first and then java $lv_java_param
    b) or java $lv_java_param is run on the fly......
    Any help is much appreciated.

    This forum is about Oracle *RDBMS*
    I don't see any question about Oracle RDBMS
    Please find a forum about Java.
    Sybrand Bakker
    Senior Oracle DBA

  • Displaying japanese chars using servlet (posted in Java programming too)

    I am trying to display the japanese characters inputed by the user using
    html form and I am using servlet...
    After reading the input and when i try to display i get ????
    how can i solve this.
    It was originally posted in Java Programming forum. but i think the question suits here....heres the link for original post
    http://forum.java.sun.com/thread.jspa?threadID=670419&tstart=0
    sorry for posts at two different forums

    After reading the input and when i try to displayDisplay on what?
    Usually, if request.getCharacterEncoding() doesn't return viable result, then you should call
    request.setCharacterEncoding() with a proper value. If user send Shift_JIS string as form
    input, then the argument value should be also "Shift_JIS". When in doubt, use "UTF-8".
    Then, you call response.setContentType("text/html; charset="Shift_JIS"), etc.

  • Passing collection parameters from/to Oracle 8i stored procedure to/from Weblogic java program

    Environment- Oracle DB 8.1.7 (Sun) - JDBC OCI 8.1.7 - Application Server (WebLogic 6.0 or 6.1)QuestionHow to pass oracle collection data types from PL/SQL stored procedures to Weblogic java program as in/out stored procedures parameters. I am hitting oracle error 2006 unidentified data type trying to pass the following data types:-o java.sql.Structo java.sql.Arrayo oracle.sql.STRUCTo oracle.sql.ARRAYo oracle.jdbc2.Structo oracle.jdbc2.Arrayo any class implemented oracle.jdbc2.SQLData or oracle.sql.CustomDatumInformationAbout PL/SQL stored procedure limitation which only affects the out argument types of stored procedures calledusing Java on the client side. Whether Java methods cannot have IN arguments of Oracle 8 object or collection type meaning that Java methods used to implement stored procedures cannot have arguments of the following types:o java.sql.Structo java.sql.Arrayo oracle.sql.STRUCTo oracle.sql.ARRAYo oracle.jdbc2.Structo oracle.jdbc2.Arrayo any class implemented oracle.jdbc2.SQLData or oracle.sql.CustomDatum

    this is becoming a mejor problem for me.And are you storing it as a blob?
    Oracle doesn't take varchars that big.
    And isn't LONG a deprecated field type for Oracle?
    From the Oracle docs......
    http://download-west.oracle.com/docs/cd/B13789_01/server.101/b10759/sql_elements001.htm#sthref164
    Oracle strongly recommends that you convert LONG RAW columns to binary LOB (BLOB) columns. LOB columns are subject to far fewer restrictions than LONG columns. See TO_LOB for more information.

  • Pass the BPEL Input Payload to Embedded Java Program

    Please let me know how can we pass the Input to a BPEL process to the embedded Java Program.
    Requirement:
    To pass the payload recieved by the BPEL process to a Java method using embedded java activity where we can parse/modify this payload
    I tried this approach
    Object obj = (Object)getVariableData('variableName');
    //call to java method with obj as argument
    //In java method
    XMLElement xmlElement = (XMLElement)obj;
    thereafter I am trying to read the nodes of this element but this is not working.
    Please point me to any document/tutorial/examples in this context.
    Thanks

    Hi
    the getVariableData() method returns a org.w3c.dom.Element object (10.1.3 version).
    So I believe you should use something like:
    Object obj = (Object)getVariableData('variableName');
    //call to java method with obj as argument
    //In java method
    org.w3c.dom.Element xmlElement = (org.w3c.dom.Element)obj;
    And to read a node use this:
    org.w3c.dom.Node node = xmlElement.getFirstChild().getNodeValue();
    However I never tried getVariableData('variableName'), I tried getVariableData('variableName','partName','query') so I don´t know the diferences between these two methods, but I hope this helps you.

  • Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type a

    Dear Team,
    Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type. Could you please do needful. Thank you

    Hello,
    most recent patches for IGS and kernel installed. Now it works.

  • Java PrintService printing Chinese/Japanese characters output is garbled.

    Hi Java Gurus,
    I have been spending the whole day trying to make our text printing application able to print non-western Characters (e.g. Chinese and Japanese) as part of our requirements. But I am constantly getting garbled output when I print a UTF-8 formatted text file containing Chinese characters. I've been trying to switch the DocFlavor types (e.g. byte array in UTF 8, input stream auto sense, UT8-8, etc) but I couldn't simply make it work.
    Here is our test method:
         public void testPrintText(String fileName) throws Exception {
              FileInputStream textStream = new FileInputStream(fileName);
              File file = new File(fileName);
              String fileContent = FileUtils.readFileToString(file);
              DocFlavor flavor = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8;
              //DocFlavor flavor = DocFlavor.READER.TEXT_PLAIN;
              InputStreamReader isr = new InputStreamReader(textStream, "utf-8");
              DocAttributeSet das = new HashDocAttributeSet();
              //System.out.println("host encoding: " + flavor.hostEncoding);
              Doc mydoc = new SimpleDoc(fileContent.getBytes("utf-8"), flavor, das);
              //Doc mydoc = new SimpleDoc(textStream, flavor, das);
              PrintRequestAttributeSet pas = new HashPrintRequestAttributeSet();
              pas.add(new PrinterName("\\\\fsinec\\Canon iR5055 PCL6", null));
              PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, pas);
              PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
              System.out.println("DEBUG: " + defaultService.getClass().getName());
              if(services.length == 0) {       
                   if(defaultService == null) {
                        //no printer found
                   } else {            
                        //print using default
                        DocPrintJob job = defaultService.createPrintJob();
                        job.print(mydoc, pas);
              } else {        
                   //built in UI for printing you may not use this
                   PrintRequestAttributeSet attSet = new HashPrintRequestAttributeSet();
                   for(int ctr=0; ctr<services.length; ctr++) {
                        PrintService printService = services[ctr];
                        System.out.println("COTS DEBUG: " + defaultService.getClass().getName());
                   //attSet.add();
                   PrintService service = null;
                   if(services.length == 1) {
                        //assume that there is no other printer with the name \\\\fsinec\\Canon iR5055 PCL6
                        //resulting to fetch the printer services to only one (1) element.
                        service = services[0];
                   /* open a dialog box
                   * PrintService service =
                        ServiceUI.printDialog(null, 200, 200, services, defaultService, flavor, attSet);*/
                   if (service != null) {           
                        DocPrintJob job = service.createPrintJob();
                        job.print(mydoc, attSet);
    Please help me on this.
    Thanks.

    This could be of different reeasons...
    1) Make sure your printer is uni-code enabled.
    2) Make sure, your unicode enabled printer is configured in SAP.
    3) make sure, your printer device is supported by SAP. (You can find list of SAP recommended printers in www.service.sap.com)
    4) Check whether the correct device type is used for printing chinese and japanese characters.
    5) Check code pages.
    6) Make sure you use Cyrillic font family, for printing chinese and Japanese characters.
    Regards,
    SaiRam

  • I need to call a java program and pass parameters from C#

    I'm new to C# and was given a project to rewrite some of my old VB.net programs to C# to help me learn.  These VB programs call quite a few .bat files that have calls to java programs in them. I'm doing okay converting my VB code, but I've been
    stumped for days trying to figure out how to call java from C#. 
    Does anyone here know how to do this?  I really should've had this figured out by now and my back is to the wall.  Ugh :(
    This is the line from the .bat file that I need to convert to C#. 
    call jvbat production_r115.Automotive m:\data\MK115mn.100 m:\data\MK115mn.101 %6
    There is one parameters being passed, %6
    I would be forever grateful if someone can show me how to do this!

    Hi Joni,
    Do you mean call a bat file that it is a Java program from C#?  If so, there is an article talking about it.
    If that's not what you're trying to do, please be more specific about what you're trying to do.
    http://www.c-sharpcorner.com/UploadFile/maheswararao/CallingJavaProgramfromCS12062005233321PM/CallingJavaProgramfromCS.aspx
    Now the next issue is pass some parameters from C#.
    The above article tells using Process.Start() method to call java program. Also  in this class, you could  specify them all in the
    Arguments property:
    var p = new Process();
    p.StartInfo.Arguments = string.Format("{0} {1}", argument1, argument2);
    For more detailed information, please refer to
    C# Passing Multiple Arguments to BAT File
    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control
    these sites and has not tested any software or information found on these sites;
    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information
    found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Custom fields mapping issue of sales order replication from R/3 to CRM

    Hello Experts, I have to replicate sales orders from R/3 to CRM system (Initial and Delta) The issue is I have custome fields in R/3 which are maintained in custom table(Z table) in R/3. We added those custom fields in CRM customer_i table to synchro

  • Help with iPod mini (Battery issues)

    I am an owner of an iPod mini (1st generation) that I bought in February from Amazon. The mini has constant battery issues that have led me to suspect a bad battery within. For instance; I leave my mini in it's charging cable overnight, and it report

  • Font Problem in Web Browser

    Dear Friends, Can Anybody help me? I have developed a report in 10g DS (on Windows XP Machine), running this report on local machine works fine. i have installed 10g AS on windows 2003 server and deployed my application there. Here, If i run on local

  • Problem with Broadcasting Web query

    I am able to broadcast the web query and I recieve the email in MS Outlook, but the report is unreadable. It has the proper header info (from, to, subject, ...), but the report itself shows up as garbled text ("Q29udGVudC1UeXBlOiBtdWx0aXBhcnQvcmVsYXR

  • Macbook Pro Retina Heat

    Hi. I'm completely new to Mac and OSX but I'm fairly good with computers. Beening building PCs for years and know my way around Windows. I'm a little concerned with my Macbook Pro Retina and its heat. I understand that its a slim computer and its goi