×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Exclamation image in eclipseme

    Hello ,

    I am using eclipse with eclipseme.I have created one sample project in which i have one midlet and i want to put image in my jar.so i have put the image in res folder but still it is giving exception IO .here is my code

    pic1 =Image.createImage("/res/dairy.png") ;

    also i have tried like this


    pic1 =Image.createImage("/dairy.png") ;

    where should i put the image?

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    Hello ,

    I am using eclipse with eclipseme.I have created one sample project in which i have one midlet and i want to put image in my jar.so i have put the image in res folder but still it is giving exception IO .here is my code

    pic1 =Image.createImage("/res/dairy.png") ;

    also i have tried like this


    pic1 =Image.createImage("/dairy.png") ;

    where should i put the image?


    Hey,
    IS there any exception /alerts/errors shown by the device,
    Just put the image inside the RES folder,

    Okey,then you create the image.
    Image.cretaeImage("/nameof the image);
    see what happens,


    then
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    hi
    I did the same.I tried by putting the image in res .still it is giving me IO exception

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    hi
    I did the same.I tried by putting the image in res .still it is giving me IO exception
    Hey,
    Is this exception is thrown on the emulator or device?
    Let me tell you IOException will be thrown in case of you have write the wrong name of the image..
    Please check the same,you have typed the correct name of the image.

    Can you take the cursor on the image,press F2 and copy the name of the image and just paste the same in the code...
    Make sure that your image is PNG...
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    hey thanks
    but i tried all the things that u have sid..image in png only..same code is working in netbeans but i want it to run in eclipse. in netbeans i had put it in src folder itself but in eclipse it must be in res so i put that to res folder..still exception is coming IOException and its in console..

    see code again


    try
    {
    pic1 =Image.createImage("/dairy.png") ;
    item0=new ImageItem("temp",pic1,1,"0",2);
    item0.setPreferredSize(60,60);
    nform=new Form("New Form");
    nform.append(item0);
    display.setCurrent(nform);
    }
    catch(Exception e)
    {
    System.out.println(e);
    }

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    hey thanks
    try
    {
    pic1 =Image.createImage("/dairy.png") ;
    item0=new ImageItem("temp",pic1,1,"0",2);
    item0.setPreferredSize(60,60);
    nform=new Form("New Form");
    nform.append(item0);
    display.setCurrent(nform);
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    Hi,
    Up to which line the control,is coming in the code.Just put the println()'s after the every statement...ok and check that upto which line it comes,


    Now you can do one more thing about it is that you copy the res and src folder and through the eclipse create the new project and then paste the same copied data there,
    please do this...i guess something is wrong with the project itself,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    hey thanks
    i dunno how but it worked suprisingly..i havent done any changes??What are the differences in netbeans and eclipse???i am getting many warnings as i have exported my netbeans project to eclipse..and one more thing where the rms files get stored in PC???i couldnt find it..

  8. #8
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    hey thanks
    i dunno how but it worked suprisingly..i havent done any changes??What are the differences in netbeans and eclipse???i am getting many warnings as i have exported my netbeans project to eclipse..and one more thing where the rms files get stored in PC???i couldnt find it..
    Hi.
    Just tell me that have you remove the IOException?
    You can not just run the project created by netbeans in the eclipse directly,
    There is no any specific difference between the two IDE's.However you will find the different directories names under the project directory...Another thing is that in case of netbeans IDE, you can put the all images in the folder and give the name as you want to give.However you cannot make the name of the folder other than res.

    you just go and see the project in both of the cases,

    For the RMS path,you tell us that on which emulator you are working with?
    In case of the WTK,you can just move to the emulator_name and then APPDB,in this you will find the rms file.

    give more information about the same,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  9. #9
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    Thanks
    yes i know that we cannot just import project in eclipse from netbeans..i did it manually.i also know that in netbeans we can give name as we want but in eclipse i made floder named images. they are working fine but another folder named "info" which contains text files which i want to use are not running properly..

    filename="/info/snacks/snacks.txt";
    InputStream is = getClass().getResourceAsStream(file_name);

    this is he code.

  10. #10
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    Thanks
    yes i know that we cannot just import project in eclipse from netbeans..i did it manually.i also know that in netbeans we can give name as we want but in eclipse i made floder named images. they are working fine but another folder named "info" which contains text files which i want to use are not running properly..

    filename="/info/snacks/snacks.txt";
    InputStream is = getClass().getResourceAsStream(file_name);

    this is he code.
    Hey,
    What exception you are getting..?
    Is it null pointer exception,
    Can you try by putting the txt file in the same folder where you have put the images,
    Just try this,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  11. #11
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    now i have txt in res folder and image also..image is workin fine but not txt file..it is throwing an exception null pointer.....

  12. #12
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    actually i m extracting words from text file and creating inputstream and strinbuffer i m appending it to choice group
    "is" is inputstream object.


    is = getClass().getResourceAsStream(file_name);
    StringBuffer sb = new StringBuffer();
    System.out.println("Stringbuffer:"+sb);

    system.out.println statement is giving o/p loke this

    Stringbuffer:

    and this is d exception : Unable to create streamjava.lang.NullPointerException

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    now i have txt in res folder and image also..image is workin fine but not txt file..it is throwing an exception null pointer.....
    Hey,
    Let me make it more clear and short...
    @ please create the project using eclipse,
    @ it will create the all needed directories for you.
    @ put the all image,txt file in the folder called as res.
    @ then make sure that you can draw any image you have inside the res,if you have loaded that by using the createImage()...
    @ then you can check that the txt file is also readable and there is no exception..
    the code for reading the txt file is as follow-
    StringBuffer stationBufferTxt = new StringBuffer();
    public String readDataFromTxt()
    {
    int ch;
    try
    {
    InputStream inStream = getClass().getResourceAsStream("/nameFile.txt");

    while ((ch = inStream.read()) != -1)
    {
    stationBufferTxt.append((char) ch);
    }
    return stationBufferTxt.toString();
    }
    catch (Exception e)
    {
    System.out.println("Exception caucght file reading..." + e.toString());
    }
    return null;
    }
    Thats all, you have to do..nothing else...please make sure that after fixing the all issue you can try to change the name of the res folder or any other test
    let me know about the query,if any
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  14. #14
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: image in eclipseme

    hello
    i did all already what u have written just now..he problem here is string buffer is not getting created .it is null

  15. #15
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: image in eclipseme

    Quote Originally Posted by snehalpatil View Post
    hello
    i did all already what u have written just now..he problem here is string buffer is not getting created .it is null
    you must create the same before you go and use it.Then what is the problem,jut create it.

    StringBuffer stationBufferTxt = new StringBuffer();
    liken this,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. --- ???save image problem??? ---
    By ferenn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2007-10-01, 14:33
  2. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  3. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  4. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  5. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31

Posting Permissions

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