I am trying to send a class file to offload "work" from a client to a server. I send a class file "MyClass.class" and receive it as "MyFooClass.class" successfully.
I need to execute the main() of MyFooClass at the server side and return the result.
I am trying to load the MyFooClass wit开发者_C百科h a classloader but get the ClassNotFoundException.
Kindly help.
Aditya
Unless you are doing RMI, the 'server' side won't have the class in its classpath and therefore fail with a ClassNotFoundException.
Now the bigger questions is why are you trying to send the whole class? I think it would be easier to have the class on the server and then send a text representation (json, xml, yaml, csv) of the state of the class on the client and then have the server read the representation, create the class(es) it needs and execute the work.
Yes, you should not rename the class. The classloader will search for MyFooClass.class only but available is MyClass.class..So it is throwing an exception saying the expected MyClass.class is not available.
The classname and the filename have to match. So you cannot simply rename the file.
精彩评论