Search code examples
javaappletclassloader

Load a class from a jar, in another machine, without downloading the whole Jar


I have seen two questions with same subject, but none of them seem to answer my question. How to load a jar from an URL without downloading it?
Get files from Jar which is on the repository without downloading the whole Jar from Java

I, in an applet, would like to download classes from a Jar file inside the server, but without downloading the whole jar file. Is it possible?


Solution

  • in an applet, would like to download classes from a Jar file inside the server, but without downloading the whole jar file

    If you have control over server code, write a servlet and then call the servlet with appropriate query to pull the required class in the jar. Something like following:

    http://myserver.com/myservlet?download_class=x.y.z.class&jar_file=my.jar
    

    The applet will call on above URL. At the server, your servlet will pick the jar file and extract the required class and then send it across (using ServletOutputStream) to to the applet.

    I think above should work for you.