No such method error

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

No such method error

Postby DeQiu » Mon Jan 28, 2008 5:19 pm

I get Java Exception:

Class: 6 - no such method error
Method: 232 - <init>(Llejos/nxt/TachoMotorPort;)V

I compiled my program without any error. What is wrong ?
DeQiu
New User
 
Posts: 14
Joined: Wed Jan 09, 2008 9:55 pm

Postby roger » Mon Jan 28, 2008 6:22 pm

Possibly the version of classes.jar that the compiler uses in not the same as the one used the the linker. This can happen in Eclipse. What IDE are you using?
Roger
roger
Moderator
 
Posts: 363
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Postby DeQiu » Mon Jan 28, 2008 7:15 pm

I'm using NetBeans IDE 5.5.1 but I'm using command: nxjc and nxj to compile and link my program.
DeQiu
New User
 
Posts: 14
Joined: Wed Jan 09, 2008 9:55 pm

Postby roger » Mon Jan 28, 2008 8:34 pm

Not being a NetBeans user, I don't know if I can help. How many copies of classes.jar do you have? Are they by chance from different revisions?
roger
Moderator
 
Posts: 363
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Postby DeQiu » Mon Jan 28, 2008 9:58 pm

I'm using only one classes.jar

I noticed that when I directly call any method from Motor class (for example setSpeed) from main method, this situation (Exception NoSuchMethodError) doesn't appear. Its opposite when I'm calling method for example setSpeed throughtout other methods created by me.
DeQiu
New User
 
Posts: 14
Joined: Wed Jan 09, 2008 9:55 pm

Postby DeQiu » Mon Jan 28, 2008 10:37 pm

This code produces exception NoSuchMethodError:

Code: Select all
class Master {

   public static void main(String[] args) throws Exception{

   // {...}
   new MotorTest().start();
   // {...}

   }
}


class MotorTest extends Thread {

   public void run(){
     
      servo.stop('A');
      while(true);

   }
}

Code: Select all
import lejos.nxt.Motor;

public class servo{

   static Transfer transfer;
   private static byte[] bufor={0,0,0,0,0,0};
   
   
    static void stop(char port){
       
        if(port=='A') Motor.A.stop();
        else if(port=='B') Motor.B.stop();
        else if(port=='C') Motor.C.stop();
        else if(port=='D'||port=='E'||port=='F'){        // for remote NXT
            bufor[0]=2;
            bufor[1]=(byte)((port=='D')?(1):(port=='E')?(2):(3));
            bufor[2]=3;
            bufor[3]=0;
            bufor[4]=0;
            bufor[5]=0;
            transfer.send(bufor);
        }
    }
}


This code doesn't produce exception:

Code: Select all
class Master {

   public static void main(String[] args) throws Exception{

   // {...}
   servo.stop('A');
   // {...}

   }
}

And class servo is the same.
DeQiu
New User
 
Posts: 14
Joined: Wed Jan 09, 2008 9:55 pm

Postby roger » Tue Jan 29, 2008 6:42 am

I tried both versions of your Master class and they both run on my system without errors.
Sorry I can't help - I've run out of ideas. Anyone else have one?


Roger
roger
Moderator
 
Posts: 363
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Postby lawrie » Wed Jan 30, 2008 12:36 am

You might have a different version of MotorTest.class on your CLASSPATH.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

cron
more stuff