Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

NoSuchMethodError

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
thibal
Asked:
thibal
  • 4
  • 3
1 Solution
 
thibalAuthor Commented:
Edited text of question
0
 
thibalAuthor Commented:
Edited text of question
0
 
fontaineCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
fontaineCommented:
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
 
thibalAuthor Commented:
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
 
thibalAuthor Commented:
I don't know what method can provocate this exception.
Have you an idea?
0
 
fontaineCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now