DNP, I have another problem now. The first one might still exist. Sorry to bug you. After I compile this program in Windows, why do I have multiple class files for the same program (like name of the program say is xxx.class, I have xxx$1.class, xxx$2.class, xxx$3.class etc.) in my DOS directory. I can't move these files to UNIX because the $ means something there. I moved the one xxx.class to UNIX and when I run it there, I get the following (stack trace):
Exception in thread "main" java.lang.NoClassDefFoundError: DldRepUnix$1
at DldRepUnix.initComponents(DldRepUnix.java:86)
at DldRepUnix.<init>(DldRepUnix.java:18)
at DldRepUnix.main(DldRepUnix.java:181)
*** Note: xxx = DldRepUnix (name of the program)
Is this normal to have these type of class files for one program which has only one class xxx? I am new to Java Programming too. So excuse my ignorance here.
Thanks.
: Why don't you post me the stack trace? I might be able to give you something more concrete.
:
: I haven't encountered this problem, but I do know that there is one place where a potential for NoSuchMethodException is present in Swing. It's in the ProxyLazyValue inner class (and its friends and family). That class uses reflection to call methods based on string versions of their name. Normally, it's pretty tightly controlled, checked so that sort of thing doesn't happen, but if someone starts subclassing the various elements of the look and feel and isn't vigilant about them, it can sneak in.
:
: Anyway, give me the stack trace, and I'll take a look at it.
:
: DNP
:
: : Thanks for your quick feedback. Here is some more info'. I compiled and ran this program in Windows. Runs perfectly fine. When I moved the class file to UNIX and run it there, I get a 'NoSuchMethodError'. I don't know whether the JRE version matters here. It seems like it is not recognizing one of the swing component method calls. It doesn't tell me which method call broke it. How can I capture this problem method call? Based on your note, how can I know which method call can throw a NoSuchMethod exception. Is there a way I can do a catch all type at a global level for this 'specific' exception? Thanks again.
: :
: : : Hi back.
: : :
: : : What you're doing wrong is exactly what the compiler's telling you. You're trying to catch an error that's not even potentially thrown by the code.
: : :
: : : You see, the try statment catches the exceptions in its block only. Think of it this way:
: : :
public void myMethod() {
: : :
: : : // Exceptions here will not be caught.
: : :
: : : try {
: : :
: : : // Only exceptions here will be caught.
: : :
: : : } catch (NoSuchMethodException e) {
: : :
: : : // Exceptions here won't get caught, obviously.
: : :
: : : }
: : :
: : : // Exceptions here won't get caught either.
: : :
: : : }
: : :
: : : Since the only statement in your try block is a call to a component's setBounds method, and the setBounds method has no possibility of throwing a NoSuchMethodException, you're trying to catch an error that will never be thrown.
: : :
: : : If you are getting NoSuchMethodExceptions from some other place, then you need your try block to be where they are coming from.
: : :
: : : Hope I'm understanding your problem correctly...
: : :
: : : DNP
: : :
: :
: :
:
: