Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2007

    Question ClassCast Exception with DirectGraphics

    hi everyone...

    here i am with another problem.....

    i am running my project with apache-ant-1.6.2 and using Series 60 3rd edition emulator.
    the project compiles fine. but gives following error at run time..

    [exec] java.lang.ClassCastException
    [exec] at com.nokia.mid.ui.DirectUtils.getDirectGraphics(+1)
    [exec] at GameImage.<init>(+75)
    [exec] at GameShell.initializeGame(+14)
    [exec] at GameShell.keyMenuState(+204)
    [exec] at GameShell.keyPressed(+45)
    [exec] at javax.microedition.lcdui.Canvas.callKeyPressed(+19)
    [exec] at javax.microedition.lcdui.Display$DisplayAccessor.keyEvent(+198)
    [exec] at javax.microedition.lcdui.Display$DisplayManagerImpl.keyEvent
    ( +11)
    [exec] at com.nokia.phone.sdk.concept.event.CoreEventHandler.keyEvent
    [exec] at com.nokia.phone.sdk.concept.event.CoreEventHandler$QueuedEventHandler.
    run (+123)

    I checked the code. it gives error at the run time while executing this line.
    I have imported DirectGraphics and DirectUtils in file.

    DirectUtils.getDirectGraphics(g).getPixels(pi, 0, dx, 0, 0, dx, dy, 4444);

    please help me..


  2. #2
    Registered User
    Join Date
    Jan 2007

    Re: ClassCast Exception with DirectGraphics

    i tried this too..

    DirectGraphics dg = DirectUtils.getDirectGraphics(g);
    dg.getPixels(pi, 0, dx, 0, 0, dx, dy, 4444);

    but the result is same.......

  3. #3
    Super Contributor
    Join Date
    Apr 2003
    USA, CA

    Re: ClassCast Exception with DirectGraphics

    What is the type of "pi" and the rest of the variables in the parameter list?


  4. #4
    Registered User
    Join Date
    Jan 2007

    Re: ClassCast Exception with DirectGraphics

    all variables are of int type.
    here is the definition and the piece of the code for initializing them

    private int pi[];
    int dx;
    int dy;

    dx = img.getWidth();
    dy = img.getHeight();
    int dxy = dx * dy;
    Graphics g = Image.createImage(dx, dy).getGraphics();
    pi = new int[dxy];

  5. #5
    Super Contributor
    Join Date
    Mar 2003

    Re: ClassCast Exception with DirectGraphics

    The 4444 format uses a short (16 bit) array.


  6. #6
    Registered User
    Join Date
    Jan 2007

    Unhappy Re: ClassCast Exception with DirectGraphics

    thanks shmoove
    i corrected it.
    but as i said
    .... DirectGraphics dg = DirectUtils.getDirectGraphics(g);
    this line is giving problems.
    when i comment getPixels() line still it gives error....!
    i guess i am mistaking somewhere ..
    Here is my build.xml code

    <!-- ............ Build: NOKIA 60 MIDP.............. -->
    <target name="buildnokia60" depends="init">
    <property name="wtk.home" value="C:\WTK22"/>
    <property name="name" value="Commando"/>
    <property name="dev" value="nokia60"/>
    <property name="appres" value="NokiaRes/60"/>
    <property name="path" value="NokiaBuild/60/"/>
    <property name="midplib" value="C:\midpapi.zip"/>
    <antcall target="build"/>
    <!--..............Run nokia...................-->
    <target name="runnokia60" depends="buildnokia60">
    <exec executable="C:\WTK22\bin\emulator.exe">
    <arg line="-classpath ${path}/Commando.jar" />
    <arg line="-Xdescriptor:${path}/Commando.jad"/>
    <arg line="-Xdevice:Series_60_MIDP_Concept_SDK_Beta_0_3_Nokia_edition" />
    <!--....................END NOKIA 60 MIDP1.................................-->

    in midplib classpath i have given the c:\midpapi.zip.
    In this archive i have added all apis including NOKIA UI.
    For nokia ui i have added five class files to the midapi.zip archive manually.


    Temporarily i am running project in SonyK700 emulator.
    But i need to use NOKIA emulator.

    Please help me

Similar Threads

  1. VS.Net 2003 Carbide 2.01 and epoc32.exe
    By ValentinK in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2007-01-12, 12:31
  2. First-chance exception in emulator S60 3rd ed.
    By darioses in forum Symbian Tools & SDKs
    Replies: 6
    Last Post: 2006-04-25, 18:24
  3. ClassCast Exception while playing Audio Sounds during Sound Interjection
    By amitkumar_j2me in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2005-06-23, 07:17
  4. Catching an exception
    By btnokdev in forum Mobile Java General
    Replies: 2
    Last Post: 2003-10-11, 14:45
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

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