File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collector program does not run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collector program does not run" Watch "Garbage Collector program does not run" New topic
Author

Garbage Collector program does not run

tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
when i run the code below given in K&B book , to find memory deallocated it runs perfectly and gives output




but when i write a similar code , given below



i get a error



why so ? only changing class name gives this error ? is CheckGC a predefined class ?


Do Right , Fear No Man
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18541
    
  40

why so ? only changing class name gives this error ? is CheckGC a predefined class ?


Question. When you changed the name of the class, did you also change the name of the source file, and recompile?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18541
    
  40

Exception in thread "main" java.lang.NoClassDefFoundError: garbage/java



Oh.... did you happen to run it as....

> java garbage.java

instead of ...

> java garbage

Henry
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Garbage Collector program does not run
 
Similar Threads
y aint here class <classname>=new <classname> used and instead only class <classname> used
Garbage Collection Help!
Garbage collection example code from K&B
Doubt about garbage collection
Doubt in GC