Possible Duplicate:
Loading from JAR as an InputStream?
Is it possible for me to load a jar file from an input stream (from a url connection, for example), load it into a classloader, and execute it?
Thanks for your time.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes;
URLClassLoaderis intended for this purpose. It can load classes from an array of URLs.If your
InputStreamis not based on aURL, you could instead write the stream’s contents to a temporary jar file which you then load using the above approach. (You can load a jar entirely in memory, meaning no temp file is created, but this method takes considerably more effort to do right, because you will need define a custom ClassLoader).