×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    Oct 2009
    Location
    Delhi
    Posts
    124

    Base64 import error

    Hi
    i want to use the Base64 encoder and decoder in my app...for that i am using

    import com.sun.midp.io.Base64;

    in the java tool kit emulator its working fine, but when i tried it on the nokia emulator for S40 its not working...can anyone help me on this...

    The error i am getting is
    No class DefFound Error
    java/lang/NoClassDefFoundError
    com/sun/midp/io/Base64

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Base64 import error

    try using this class

    PHP Code:
    /*
     * Base64.java
     *
     * Created on July 23, 2009, 2:53 PM
     *
     * To change this template, choose Tools | Template Manager
     * and open the template in the editor.
     */

    /**
     *
     * @author SAgnihotriLTech
     */
    package org.opendmtp.j2me.client.custom.motorola;

    //Base64 class required for encryting email

    class Base64
    {

        private static   
    char[]  map1         = new char[64];
           static 
           {
              
    int  i  0;
              for ( 
    char c 'A'<= 'Z'c++ ) {
                 
    map1[i++] = c;
              }
              for ( 
    char c 'a'<= 'z'c++ ) {
                 
    map1[i++] = c;
              }
              for ( 
    char c '0'<= '9'c++ ) {
                 
    map1[i++] = c;
              }
              
    map1[i++] = '+';
              
    map1[i++] = '/';
           }
     
           public static 
    String base64Encodebyte[] in 
           {
              
    int     iLen      in.length;
              
    int     oDataLen  = ( iLen ) / 3;// output length without padding
              
    int     oLen      = ( ( iLen ) / ) * 4;// output length including padding
              
    char[]  out       = new char[oLen];
              
    int     ip        0;
              
    int     op        0;
              
    int     i0;
              
    int     i1;
              
    int     i2;
              
    int     o0;
              
    int     o1;
              
    int     o2;
              
    int     o3;
              while ( 
    ip iLen 
              {
                 
    i0 in[ip++] & 0xff;
                 
    i1 ip iLen in[ip++] & 0xff 0;
                 
    i2 ip iLen in[ip++] & 0xff 0;
                 
    o0 i0 >>> 2;
                 
    o1 = ( ( i0 ) << ) | ( i1 >>> );
                 
    o2 = ( ( i1 0xf ) << ) | ( i2 >>> );
                 
    o3 i2 0x3F;
                 
    out[op++] = map1[o0];
                 
    out[op++] = map1[o1];
                 
    out[op] = op oDataLen map1[o2] : '=';
                 
    op++;
                 
    out[op] = op oDataLen map1[o3] : '=';
                 
    op++;
              }
              return new 
    Stringout );
           } 

    Regards,
    Saurabh

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Base64 import error

    Quote Originally Posted by bejoy_ak View Post
    Hi
    i want to use the Base64 encoder and decoder in my app...for that i am using

    import com.sun.midp.io.Base64;

    in the java tool kit emulator its working fine, but when i tried it on the nokia emulator for S40 its not working...can anyone help me on this...

    The error i am getting is
    No class DefFound Error
    java/lang/NoClassDefFoundError
    com/sun/midp/io/Base64
    You cannot use classes that are not described in the API documentation. Other classes are part of the implementation, and may or may not exist on other devices. Use the code kindly provided by ingsaurabh.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Delhi
    Posts
    124

    Re: Base64 import error

    thanks to both of you
    problem solved...

  5. #5
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: Base64 import error

    what did u do to solve the problem i am getting the same problem now...can you help me out..........

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Base64 import error

    Quote Originally Posted by rahul.chadalawada View Post
    what did u do to solve the problem i am getting the same problem now...can you help me out..........
    You can use base64.java provided by Saurab in this email thread below and place it at the right place in your project - set the path match to its location in your project folder in the Import command line and it will work.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  7. #7
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Base64 import error

    Quote Originally Posted by rahul.chadalawada View Post
    what did u do to solve the problem i am getting the same problem now...can you help me out..........
    You have already initiated a thread on the similar issue and you have got responses there http://www.developer.nokia.com/Commu...base64-encoder

    Regards
    Gopal

  8. #8
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: Base64 import error

    But those wernt working for j2me....

  9. #9
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Base64 import error

    Quote Originally Posted by rahul.chadalawada View Post
    But those wernt working for j2me....
    What is the issue you are getting ?

    Regards
    Gopal

  10. #10
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: Base64 import error

    when used those library .at run time i got an error class not found exception....

    but this code worked ....and now i have a problem can i send the encoded String through url..becz i am sending lattitude and longitude through url and i wish to attach this base64 string to them...is it possible....

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Base64 import error

    yes, you can send use standard Java URL encoding to send your base64 string in the URL to the server.
    You can send it as a query string with your GET request or send it as a parameter in your POST request.

    You can also refer to http://www.coderanch.com/t/229071/JM.../URL-Encode-ME for url encoding in J2me
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  12. #12
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Base64 import error

    Quote Originally Posted by rahul.chadalawada View Post
    when used those library .at run time i got an error class not found exception....
    Have you bundled the 3rd party libraries you have used along with the JAR ? Is the JAR file obfuscated ?

    Quote Originally Posted by rahul.chadalawada View Post
    but this code worked ....and now i have a problem can i send the encoded String through url..becz i am sending lattitude and longitude through url and i wish to attach this base64 string to them...is it possible....
    How about using an XML based solution ?

    Regards
    Gopal

  13. #13
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: Base64 import error

    @im2amit
    hm thanku..but the image base64encoded string is long...so i was thinking to send in post method....

    @balagopalsk
    yes i imported but its working in general java program........but its not working in midlet program...

    i am new to j2me how should i use xml...?

  14. #14
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Base64 import error

    using Post shall solve your purpose of sending the base64encoded image to the server.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  15. #15
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: Base64 import error

    Quote Originally Posted by im2amit View Post
    using Post shall solve your purpose of sending the base64encoded image to the server.
    yea i used post method but its showing the same problem...does a url has limited number of data...to be sent....

Similar Threads

  1. error LNK2019: unresolved external symbol ???
    By wgarnett in forum Symbian
    Replies: 3
    Last Post: 2009-09-28, 06:53
  2. Error in buliding a j2me project
    By siyamudheen in forum Bluetooth Technology
    Replies: 3
    Last Post: 2009-05-11, 06:28
  3. please help cell id
    By perthachy in forum Symbian
    Replies: 12
    Last Post: 2007-07-10, 13:14
  4. My BuilderX (with S60 SDK 2.1.NET MS version) cannot build ARMI UREL
    By danielvidonyi@hotmail.com in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-05-04, 21:30
  5. Unresolved external symbols problem
    By georgica1979 in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-04-06, 13:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×