Solved

NoSuchMethodError

Posted on 1998-06-19
7
154 Views
Last Modified: 2010-03-30
When I run my server program on the server machine, there is a NoSuchMethodError.
When I run the same server program on an other machine, the error does not happened.
What is the reason ?

Thanks a lot for your interest in this question.
What can I do ?
This server program is a thread it is running with the MS VJ++ jdk.
0
Comment
Question by:thibal
  • 4
  • 3
7 Comments
 

Author Comment

by:thibal
ID: 1223395
Edited text of question
0
 

Author Comment

by:thibal
ID: 1223396
Edited text of question
0
 
LVL 5

Accepted Solution

by:
fontaine earned 50 total points
ID: 1223397
I post as an answer what seems the most realistic cause of this problem, being given the
information provided. Reject if this does not help you.

You are probably using some JDK 1.1 methods and the other machine does only
understand Java code from the prior API version, 1.0. To know what version of the JDK you
are using, you can type java -version, or something similar if you are not working with
SUN's JDK. Also, I think that Microsoft has introduced some methods that are not part
of the standard Java API. If you are using them, a "pure Java" VM will throw a
"NoSuchMethodError" when trying to execute them. You should read the doc. of the
method that has thrown the exception, there sould be something that tells you since
what version of Java the method is available.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:fontaine
ID: 1223398
To fix the problem, you will have either the upgrade the VM of the other machine or to replace
the method by something equivalent but that only uses classes and methods from the
API version supported by the other machine.
0
 

Author Comment

by:thibal
ID: 1223399
Fontaine,
Your answer is probably a good one because I find this server program in "Java in a nutshell".
I've got the VisualJ++ 1.0.
But I am surprised because my code is compiled without any error or warning...
0
 

Author Comment

by:thibal
ID: 1223400
I don't know what method can provocate this exception.
Have you an idea?
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1223401
I see that I have mixed up the two machines: if it does not run on the server machine, it is
the VM of the server machine that is outdated compared to the code of your book. The
best analogy for your problem is the writing of applets. If you write an applet using methods
that are specific to JDK 1.1, all will compile fine if you work with a JDK 1.1 environment. If
you then try the applet in a non-JDK 1.1 browser, it will throw a NoSuchMethodError when
trying to access these methods. All methods that are part of the JDK 1.1 API can led
to this exception if the program is run on an old VM.

Example of method specific to the 1.1 API:

public byte[] getBytes(String enc); of java.lang.String

Normally, you should have in the error message the name of the method or at least a line
where the exception has occured. If you don't see these information, you should take a look
at the doc. of the VM: there is probably a flag to set before running the app.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now