
How can I set classpath for java classes through java code..so that i dont need to set it manually.. It should get set through my application?

Hi,
You can set the classpath while starting the program. There no general use of setting class path from the Java program.
The servers like Tomcat and other manually sets the jar files present in the WEB-INF/lib directory.
Please let me know which jar files you want to set in Java class.
Unless you are developing the applications like tomcat you really don't need this functionality.
Thanks

Hi,
Following code might be useful:
URL[] urls = null;
URL url = new URL("jar:file::///c://myjarfile.jar!/");
urls = new URL[]{url};
URLClassLoader loader = new URLClassLoader(urls);
loader.loadClass("com.MyClass");
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.