This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
i hava a java program that uses an external tool that reads a wsdl and generates some java files and .class.
then i want to use reflection to this files and call some methods but i get class not found exception is there a way to solve this problem??
i read something about setting the classpath through java but i did't understand much
So, you have a tool that generates Java source files? You'll have to compile those source files first, and then make sure the compiled classes are in the classpath, before you can use reflection on those classes.
Of course it would not harm in the first place to double check whether those classes really appear at the right location in the classpath.
I must admit how the normal class loading works, that is, whether this scenario works:
1) the program starts against a given classpath
2.1) it lets either java files generated and compiles them and puts them on the classpath
2.b) or it lets Java class files generated and puts them on the classpath
3) the program can access the generated classes and use them with, say, forName or reflection.
If the Java runtime scans the class path at starting time to make a list of the available classes, then putting there additional ones later won't help. I do not know, I must admit. In this case maybe a custom class loader can help.