Results 1 to 12 of 12

Thread: java compiling

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    java compiling

    hi,

    im trying to compile this source found here

    http://www.geocities.com/indearcito/...c_eng_1.31.zip

    im using the Sun Java(TM) Wireless Toolkit 2.5

    the error i got is

    Creating project "FoneCalc"
    Place Java source files in "C:\WTK25\apps\FoneCalc\src"
    Place application resource files in "C:\WTK25\apps\FoneCalc\res"
    Place application library files in "C:\WTK25\apps\FoneCalc\lib"
    Settings updated
    Project settings saved
    Building "FoneCalc"
    Build complete
    Running with storage root DefaultColorPhone
    Running with locale: English_United States.1252
    Unable to create MIDlet dct4
    java.lang.InstantiationException: Class not a MIDlet
    at com.sun.midp.midlet.MIDletState.createMIDlet(+66)
    at com.sun.midp.midlet.Selector.run(+22)
    Unable to create MIDlet dct4

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java compiling

    Did you put files in their appropriate folders?
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: java compiling

    i put only here

    Place Java source files in "C:\WTK25\apps\FoneCalc\src"

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java compiling

    you have to put the png file in the "res" folder
    and you must declare MIDlets in the project before you attempt to compile it
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: java compiling

    @ComputerJy

    you mean all midlet?

  6. #6
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java compiling

    You only have 1 midlet which is the class that extends MIDlet (indearcalc)

    I've attached a zip file that contains the project folder, copy it into the wtk\apps and open it from the KToolbar.

    Take a look at the settings, if you have other questions don't be shy to ask
    Attached Files Attached Files
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: java compiling

    it is possible to change the name instead of (indearcalc) ?

    br

  8. #8
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java compiling

    It's doable, you'll need to change the class name and the filename, then change it from the settings
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: java compiling

    Hi, i already done it..

    i tried compiling this code but no success? could you make also sample for this?

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;

    public class mastercode extends MIDlet implements CommandListener
    {
    private Display display;
    private Form form;
    private Alert alerta;
    private TextField t_imei;
    private String IMEI = "";
    private Command calcCommand = new Command("Calc", Command.OK, 1);
    private Command salirCommand = new Command("Exit", Command.EXIT, 1);
    private Command atrasCommand = new Command("Back", Command.OK, 1);

    private static char tabla1[] = {0xB1,0xB1,0x73,0x73,0xE6,0xE6,0x5A,0x5A,0xAB,0xAB,0x47,0x47,0x8E,0x8E,0x0D,0x0D,0x1A,0x1A,0x34,0x34 ,0x68,0x68,0x0B,0x0B};
    private static char tabla2[] = {0x34,0x62,0x58,0x92,0x76,0x13,0x25,0x97,0x56,0x28,0x68,0x13};
    private int unk;

    int gethalf(char donde[], int off)
    {
    int valor;

    valor = (donde[off+1] & 0xFF) << 8;
    valor |= donde[off+0] & 0xFF;
    return valor;
    }

    void sethalf(char donde[], int que, int off)
    {
    donde[off+0] = (char)(que & 0xFF);
    donde[off+1] = (char)((que>>8) & 0xFF);
    }

    void inv(char cadena[])
    {
    int i;
    char temp;

    for(i=0; i<=10; i+=2)
    {
    temp = cadena[i];
    cadena[i] = cadena[i+1];
    cadena[i+1] = temp;
    }
    }

    int calculo4a(int param0)
    {
    int r0, r1, r2;
    int i;

    r1 = unk;
    r0 = param0 << 0x10;
    r2 = r0 >> 0x10;

    for(i=0; i<=0xf; i++)
    {
    r1 = r1 << 1;
    r0 = r2;
    r0 &= 1;
    r1 |= r0;
    r2 = r2 >> 1;
    }

    r0 = r1;

    return r0;
    }

    void calculo4(char param0[])
    {
    int r0, r4, r6;

    r0 = gethalf(param0,8);
    r0 = calculo4a(r0);
    r6 = r0;
    r6 = r6 << 0x10;
    r6 = r6 >> 0x10;

    r0 = gethalf(param0,0xa);
    r0 = calculo4a(r0);
    r4 = r0;
    r4 = r4 << 0x10;
    r4 = r4 >> 0x10;

    r0 = gethalf(param0,2);
    r0 = calculo4a(r0);
    sethalf(param0, r0, 8);

    r0 = gethalf(param0, 0);
    sethalf(param0, r0, 0xa);
    sethalf(param0, r4, 0);
    sethalf(param0, r6, 2);

    r0 = gethalf(param0, 4);
    r0 = calculo4a(r0);
    r4 = r0;
    r4 = r4 << 0x10;
    r4 = r4 >> 0x10;

    r0 = gethalf(param0, 6);
    r0 = calculo4a(r0);
    sethalf(param0, r0, 4);
    sethalf(param0, r4, 6);
    }

    void calculo3(char param0[])
    {
    int r0, r1, r2, r4;
    int i;
    char[] temp = new char[0x18];

    for(i=0; i<=5; i++)
    {
    r0 = i << 1;
    r2 = gethalf(param0, r0);
    sethalf(temp, r2, r0);
    r0 = i + 6;
    r0 = r0 << 1;
    sethalf(temp, r2, r0);
    }
    for(i=5; i>=0; i--)
    {
    r1 = i << 1;
    r0 = i + 4;
    r0 = r0 << 1;
    r0 = gethalf(temp, r0);
    r2 = ~r0;
    r0 = i + 2;
    r0 = r0 << 1;
    r0 = gethalf(temp, r0);
    r0 |= r2;
    r4 = gethalf(param0, r1);
    r0 ^= r4;
    sethalf(param0, r0, r1);
    }
    }

    void calculo2(char param0[], char param1[], int off0, int off1)
    {
    int r0, r2, r3, r4, r5, r6;

    r5 = gethalf(param0, off0);
    r3 = gethalf(param0, off0+2);
    r2 = r3 << 0x10;
    r5 |= r2;
    r4 = gethalf(param0, off0);
    r6 = r4 << 0x10;
    r6 |= r3;
    r2 = r5 >> 0xa;
    sethalf(param0, r2, off0);
    r2 = r6 >> 0xa;
    sethalf(param0, r2, off0+2);
    r5 = gethalf(param1, off1);
    r2 = gethalf(param1, off1+2);
    r0 = r2 << 0x10;
    r5 |= r0;
    r4 = gethalf(param1, off1);
    r6 = r4 << 0x10;
    r6 |= r2;
    r0 = r5 >> 0xF;
    sethalf(param1, r0, off1+2);
    r0 = r6 >> 0xF;
    sethalf(param1, r0, off1);
    }

    void calculo1b(char param0[], char param1[], char param2[], char param3[], int off0, int off1, int off2, int off3)
    {
    int r0, r1, r4, r5, r6, r8, r9;
    int temp1, temp2;

    r6 = gethalf(param0, off0);
    r4 = r6 << 8;
    r9 = r4;
    r4 ^= r6;
    r5 = gethalf(param0, off0+2);
    r4 ^= r5;
    r8 = r4;
    r4 = r5 << 8;
    r5 ^= r4;
    r5 ^= r6;
    r4 = r9;
    r5 ^= r4;
    r0 = param0[off0+1] & 0xFF;
    r5 ^= r0;
    r0 = param1[off1+3] & 0xFF;
    r4 = gethalf(param1, off1+2);
    r0 ^= r4;
    r4 = r8;
    r0 ^= r4;
    r0 = r0 << 0x10;
    r0 = r0 >> 0x10;
    r1 = gethalf(param1, off1);
    r1 ^= r5;
    temp1 = r1;
    r4 = r1 << 0x10;
    r4 = r4 >> 0x10;
    temp1 = r4;
    r4 = gethalf(param2, off2+2);
    r0 ^= r4;
    r4 = gethalf(param2, off2);
    r1 = r4 << 8;
    r0 ^= r1;
    r1 = param2[off2+1] & 0xFF;
    r0 ^= r1;
    r4 = gethalf(param2, off2+2);
    r4 = r4 << 8;
    temp2 = r4;
    r0 ^= r4;
    r1 = param2[off2+3] & 0xFF;
    r0 ^= r1;
    sethalf(param3, r0, off3);
    r0 = gethalf(param2, off2);
    r4 = temp1;
    r0 ^= r4;
    r1 = param2[off2+1] & 0xFF;
    r0 ^= r1;
    r4 = gethalf(param2, off2+2);
    r1 = r4 << 8;
    r0 ^= r1;
    r1 = param2[off2+3] & 0xFF;
    unk = r1;
    r0 ^= r1;
    sethalf(param3, r0, off3+2);
    }

    void calculo1a(char param0[])
    {
    int i;
    char[] temp = new char[12];

    for(i=0; i<12; i++)
    {
    temp[i] = param0[i];
    }
    calculo1b(temp, temp, temp, param0, 0, 4, 8, 0);
    calculo1b(temp, temp, temp, param0, 4, 8, 0, 4);
    calculo1b(temp, temp, temp, param0, 8, 0, 4, 8);
    }

    void calculo1(char param0[], char param1[], char param2[], int off2)
    {
    int r0, r2, r3, r4;

    r3 = gethalf(param1, 0);
    r4 = gethalf(param0, 0);
    r3 ^= r4;
    sethalf(param1, r3, 0);

    r3 = gethalf(param0, 2);
    r4 = gethalf(param2, off2);
    r3 ^= r4;
    r4 = gethalf(param1, 2);
    r3 ^= r4;
    sethalf(param1, r3, 2);

    r3 = gethalf(param1, 4);
    r4 = gethalf(param0, 4);
    r3 ^= r4;
    sethalf(param1, r3, 4);

    r3 = gethalf(param1, 6);
    r4 = gethalf(param0, 6);
    r3 ^= r4;
    sethalf(param1, r3, 6);

    r4 = gethalf(param0, 8);
    r2 = gethalf(param2, off2);
    r4 ^= r2;
    r2 = r4;
    r4 = gethalf(param1, 8);
    r2 ^= r4;
    sethalf(param1, r2, 8);

    r4 = gethalf(param1, 0xa);
    r0 = gethalf(param0, 0xa);
    r4 ^= r0;
    r0 = r4;
    sethalf(param1, r0, 0xa);

    calculo1a(param1);
    }

    void calc_code(char param0[], char param1[], char param2[])
    {
    int r2;
    int i;

    for(i=0; i<=10; i++)
    {
    r2 = i << 1;
    calculo1(param0, param1, param2, r2);
    calculo2(param1, param1, 0, 8);
    calculo3(param1);
    calculo2(param1, param1, 8, 0);
    }

    calculo1(param0, param1, param2, 0x16);
    calculo4(param1);
    }

    char[] calc_mcode(char imei[])
    {
    char[] mi_tabla1 = new char[24];
    char[] mi_tabla2 = new char[12];
    int r0, r1;
    int i;
    char[] imei_hex = new char[12];
    char[] destino = new char[10];

    sethalf(imei_hex, 0, 0);
    sethalf(imei_hex, 0, 8);
    sethalf(imei_hex, 0, 0xa);

    for(i=0; i<=6; i++)
    {
    r0 = i << 1;
    r1 = imei[r0];
    r1 &= 0x0F;
    r1 = r1 << 4;
    r0 = imei[r0+1];
    r0 &= 0x0F;
    r1 |= r0;
    imei_hex[i+2] = (char)r1;
    }

    inv(imei_hex);
    calc_code(tabla2, imei_hex, tabla1);
    inv(imei_hex);

    r1 = 0;
    for(i=0; i<=4; i++)
    {
    r1 = i << 1;
    r0 = imei_hex[i];
    r0 = r0 >> 4;
    r0 &= 7;
    r0 += 0x30;
    destino[r1] = (char)r0;
    r0 = imei_hex[i];
    r0 &= 7;
    r0 += 0x30;
    destino[r1+1] = (char)r0;
    }

    return destino;
    }

    private void mostrar_codigos()
    {
    String txtimei;

    form = new Form("Code");
    txtimei = t_imei.getString();
    if (txtimei.length() != 15)
    {
    alerta("Error!", "Incorrect IMEI, enter 15 digits!", AlertType.ERROR);
    return;
    }

    IMEI = txtimei;

    String codigo = new String(calc_mcode(txtimei.toCharArray()));
    form.append(codigo);

    form.addCommand(atrasCommand);
    form.setCommandListener(this);

    display.setCurrent(form);
    }

    private void menu()
    {
    form = new Form("Sec.master code calc");
    t_imei = new TextField("IMEI:", IMEI, 15, TextField.NUMERIC);
    form.append(t_imei);
    form.addCommand(calcCommand);
    form.addCommand(salirCommand);
    form.setCommandListener(this);

    display.setCurrent(form);
    }

    //Mensaje alerta
    private void alerta(String titulo, String mensaje, AlertType tipo)
    {
    alerta = new Alert(titulo, mensaje, null, tipo);
    alerta.setTimeout(3000);

    display.setCurrent(alerta);
    }

    public mastercode()
    {
    display = Display.getDisplay(this);
    }

    public void startApp()
    {
    menu();
    }

    public void commandAction(Command c, Displayable s)
    {
    if (c == salirCommand)
    {
    destroyApp(false);
    notifyDestroyed();
    }
    else if (c == calcCommand)
    {
    mostrar_codigos();
    }
    else if (c == atrasCommand)
    {
    menu();
    }
    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean unconditional)
    {
    }
    }

  10. #10
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java compiling

    Instead of creating a new midlet app I added this MIDlet to the previous MIDlet suite.
    Attached Files Attached Files
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: java compiling

    how did you do that? i tried to install it on my phone it works perpectly.. on Master Code can we put also a ticker banner?

    thanks

    br

  12. #12
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java compiling

    You can't keep doing this forever. You must learn how to modify the settings, and it's very easy to add a ticker
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

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



Click Here to Expand Forum to Full Width