• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with class.forName()

 
Lakshmi Deepa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the exact stack trace? Perhaps the CacheManager class itself can be found but a class it needs cannot.
 
Lakshmi Deepa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you manually checked that the compiled class exists where you expect it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic