java.lang.NoSuchMethodError

How do i catch this error ?i've tried try{}catch{}with Exception and RuntimeException
[107 byte] By [ashcarrota] at [2007-9-28 3:50:35]
# 1

Catching any of the following would work:

java.lang.Throwable

java.lang.Error

java.lang.LinkageError

java.lang.IncompatibleClassChangeError

java.lang.NoSuchMethodError

with the top the most general and the bottom the most specific. Errors are not extended from Exceptions, rather, they are two different types of Throwables.

gyrefalcona at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

and what is the solution to this error?

let me explain my problem

i have an applet that loads from a cab file.

an inside i call a method

SecureRandom.getInstance

it works on application(the same code) but not in applet when using cab file

exact error:

-

java.lang.NoSuchMethodError:

java/security/SecureRandom: method getInstance(Ljava/lang/String;Ljava/lang/String;)Ljava/security/SecureRandom; not found

--

Yours

Andrew

xagapioua at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

To start with it shouldn't be necessary to catch this kind of error.

You're probably getting this error because when it is running as an applet it is using an older version of the java.security.SecureRandom class, which doesn't have the method you are trying to call.

regards

Nick

m7nraa at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
java.lang.NoSuchMethodError error is caught by the compiler; this error can only occur at run time.
dvohra09a at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5

> To start with it shouldn't be necessary to catch this

> kind of error.

>

> You're probably getting this error because when it is

> running as an applet it is using an older version of

> the java.security.SecureRandom class, which doesn't

> have the method you are trying to call.

>

> regards

>

> Nick

so what's the solution?

please visit this link to see what i mean:

http://forum.java.sun.com/thread.jsp?forum=423&thread=335414

xagapioua at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6

This error means that one version of the class that you call from your code was used at compile time, and an other version was used at runtime.

Try to recompile your code (I guess you have already done that) and check your class path at the place you compile and at the place you execute. There is probably some differences (Don't only check the jar names or directories imported but also their content).

If you the code that raise the exception is not your code, then it means that you have a wrong version of one (or more) jar in your classpath. Check what is in your class path and check what says the release note of the component that raise the exception.

gscokarta at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7
As I said on the other thread, your browser has maybe the wrong version of JRE.
gscokarta at 2007-7-7 23:22:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...