File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem with class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem with class.forName()" Watch "Problem with class.forName()" New topic
Author

Problem with class.forName()

Lakshmi Deepa
Greenhorn

Joined: Jan 10, 2011
Posts: 2
i have below files(both .java and .class files) in my code.

com.cvs.tpms.prm.ProductionManager
com.cvs.tpms.jms.gui.AgentApplication
com.cvs.tpms.gui.DeviceManager
com.cvs.tpms.gui.ProcessManager
com.cvs.bit.cache.ui.CacheManager

in code, i am using like this

final Class applicationClass = Class.forName(string
.asString());

string.asString() gives the path of the class i.e com.cvs.tpms.prm.ProductionManager.

I am dynamically loading the classes by using class.forName() method.

I am able to load all the classes except CacheManger.when i am trying to load the cache manager class am getting ClassNotfound Exception,but CacheManager.class exists in my code.

Could any one help me how to resolve this issue.


Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

I am able to load all the classes except CacheManger.when i am trying to load the cache manager class am getting ClassNotfound Exception,but CacheManager.class exists in my code.


Maybe because of spelling mistake between CacheManger and CacheManager.
Check it.

And Welcome to Java Ranch


Life is easy because we write the source code.....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

Can you show the exact stack trace? Perhaps the CacheManager class itself can be found but a class it needs cannot.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Lakshmi Deepa
Greenhorn

Joined: Jan 10, 2011
Posts: 2
This is the exeption i am getting

java.lang.ClassNotFoundException: com.cvs.bit.cache.ui.CacheManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.cvs.bit.gui.ControlCenter.loadApplications(ControlCenter.java:139)
at com.cvs.bit.gui.ControlCenter.<init>(ControlCenter.java:72)
at com.cvs.bit.gui.ControlCenterFrame.<init>(ControlCenterFrame.java:95)
at com.cvs.bit.gui.ControlCenter.main(ControlCenter.java:220)
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

have you manually checked that the compiled class exists where you expect it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with class.forName()