Forums Register Login

Remote Classpath Loader

+Pie Number of slices to send: Send
I have this situation where I have some class files ot jars placed on a server (server1) and the url is http://www.server1.com/classes/. The server2 has my java program on the same network. Now I want the class files or the jar files to get included in my classpath at server1. I am not allowed to physically move the class files from server1 to server2.
how can we acheive it. Is there any example?
+Pie Number of slices to send: Send
I don't think that you can directly place a URL in the classpath of your machine. To get this done I believe that you need to use a URLClassLoader. Of course the URL has to be accessable on a Web Server somewhere.
//You would create a URL object array pointing at the location of the classes and any jars at that location.
URL[] myURL = {new URL("http://www.server1.com/classes/") , new URL("http://www.server1.com/classes/myPackage.jar")};
//Then you would create URLClassLoader Object and feed it that URL object.
URLClassLoader myClassLoader = new URLClassLoader(myUrl);
//Finally you would do the load manually by
Class myClass = myClassLoader.findClass("WhateverClass");
I haven't actually tried this, so let us know how it works.
[ April 24, 2003: Message edited by: Cindy Glass ]
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1170 times.
Similar Threads
How to start or run a application on newly created server2 on WebSphere
Multiple problems with Weblogic 8.1
RMI: missing _Stub
SAX parser
How to use an EJB, deployed in another server?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:06:27.