• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

K & B Chapter 9 Q 21 Threads

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following compiles but does not run


The error message is


java.lang.NoSuchMethodError: Foo.doStuff()V
at Test12$1.run(Test12.java:23)
at java.lang.Thread.run(Unknown Source)



What did I do ...What did I do please help
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joshi,

I copy paste your code to my machine and compiled it. No problem. Then I compared your code with the code from the K&B book as you mentioned.

So here is what you need to do:

1. take out the comment '//' from your f.doStuff() line.
2. change the line 'int x = 5' to 'int x = 10' and ou will get your notify.

or try this on your machine:



Regards,
Darya
[ February 19, 2005: Message edited by: Darya Akbari ]
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could not get your error message,

Your code compiled OK and hung when executed, as it should.
 
seemapanth Joshi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am changing class name from



to


and all hell is breaking loose.

for 1st case I get error


1
2
Exception in thread "main" java.lang.NullPointerException
at Test.main(Test.java:6)



The scenario is the same in second case as mentioned in my previous post. i.e.

java.lang.NoSuchMethodError: Foo.doStuff()V
at Test12$1.run(Test12.java:7)
at java.lang.Thread.run(Unknown Source)
java.lang.NoSuchMethodError: Foo.doStuff()V
at Test12$2.run(Test12.java:13)


Thanks for looking it up but why is this happenning. Would greatly appreciate a little more light.
[ February 19, 2005: Message edited by: seemapanth Joshi ]
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joshi,

simply copy paste my code to your machine and compile it and tell me what you get.

Regards,
Darya
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seemapanth,

Like others, I had no problem running your code on a DOS prompt. How did you set the CLASSPATH? Did you upgrade to other JDK version before this? Did you use an IDE to execute the code?

Joyce
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's how I did:
1. Copied your code into a file named Test12.java
2. After compiling, 4 files: Test12.class, Foo.class, Test12$1.class and Test12$2.class were generated.
3. c:\> java Test12

However, I could able to reproduce your problem by creating a separate Foo.java that looks like this:



Compile this Foo.java after step 2 such that it overrides the existing one Foo.class. Then run java Test12. I got the following runtime error:


[ February 22, 2005: Message edited by: Joyce Lee ]
 
seemapanth Joshi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoa....I am sorry I had put it into "unresolved problem" section so went away from this forum to look at other problems related to scjp since my exam date is fast approaching. I am going to go back to my problem...clean the slate and try again ( with all your inputs )...then report back.

Greatly appreciate all the inputs. Hang on...It must be something very stupid I must have done but I have to get my finger on it.
 
seemapanth Joshi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joyce Lee,

you were right on target, my classpath did not include a "."

So there ...Everything under control and peaceful and heartfelt gratitude is in order for everybody. Thank you...Thank you... Thank you... all of you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic