Post a Job  |   Ask a Question?   |   Already registered? login or register
Ranjit Kumar
25/11/2016 12:35 PM

CustomClassloader, can anyone help me and check my code..


Spam    15 Comments

Vivek,Tiwari
25/11/2016 13:04:10
may this work... return super.findSystemClass(name);

lucky,kanth
25/11/2016 13:26:16
yup Vivek ,and one more is ,at the point of replace method u wrote '//' but it takes '/' only .try this and it works fine.

Haribabu,Kothappalli
25/11/2016 14:13:51
String classFileName=name.replace(".","/")+".class;

Ranjit,Kumar
25/11/2016 15:39:07
Thanx to All

chandru,M
26/11/2016 00:26:48
Ranjith can you tell me what you did am also getting CNF exception??? .......................................................................................................... Exception in thread "main" java.lang.NoClassDefFoundError: com/cc/beans/Toy at com.cc.test.Test.main(Test.java:12) Caused by: java.lang.ClassNotFoundException: com.cc.beans.Toy at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 1 more

Sangram,Nayak
26/11/2016 00:38:07
instead of String classFileName=name.replace(".", "//")+".class"; use String classFileName=name.replace(".", "/")+".class";

Sasmita,Moharana
26/11/2016 00:56:05
//Logic for Custom Class Loader String baseDir ="G:\\classes\\"; String classFileName=name.replace(".", "//")+".class"; can you tell me plz why we r set that path and where i will be set that path ,i'm confused where i set that path....

yasmin,sharma
26/11/2016 01:13:56
you don't need to set the path rather in case of IDE just remove the Toy.class from bin directory and then place it inside g:\classes\com\cc\beans\Toy.class folder with fully qualified name..so our own custom class loader can be able to read the class byte code from that specific path and jvm will execute it.

Sasmita,Moharana
26/11/2016 01:48:58
E:\Spring\CustomClassLoader\bin\com\ccl\beans/test/loader it's my work location,can u tell me plz where i will remove .class file and where i will be place....

yasmin,sharma
26/11/2016 10:05:35
listen i have my work directory like d:\spring |-CustomClassLoader |-bin |-com |-ccl |-beans(Toy.class) |-test(Test.class) |-loader(MyClassLoader.class) u delete only that beans folder(Toy.class) and don't delete the whole package bcoz test and loader also refering to its package and place it in the specified directory with full package name like, g:\classes |-com |-ccl |-beans |-Toy.class try it.

Ruhulla,Nakheeb
26/11/2016 16:34:56
Class<?> clazz = super.defineClass(name,byteCode, 0, byteCode.length); here remove super keyword. then it should work. becoz, if u put super.defineClass(-,-,-,-); then it always look into class path. which is bin/src/com/cc/beans/Toy.class try it once. it should work.

Sangram,Nayak
26/11/2016 16:35:04
String baseDir ="G:\\classes\\"; String classFileName=name.replace(".", "//")+".class"; Instead use this String baseDir ="G:\\classes\\"; String classFileName=name.replace(".", "/")+".class"; and remove beans folder from E:\Spring\CustomClassLoader\bin/com/ccl/ and paste inside your location like G:\classes\com\ccl\beans\Toy.class It will work

Ranjit,Kumar
27/11/2016 23:52:40
chandru,M don't worry your code is also correct, I think many of friends provide solution, there is not problem in code ,just you need to follow the rules it will work properly and remove super from super.defineClass(-,-,-,-);

khasim,vali
27/11/2016 23:57:33
hell times i tried but not working , i cant getridoff this nullpointer exception. can any one upload your successed code in post......

Amaresh,Baral
29/11/2016 23:50:12

Languages :
xml