简体   繁体   中英

How do you download a a jar file with java?

I'm trying to implement an updates feature in my program. If an update is available, there will have to be one if not several different .jar files that must be downloaded. I'm having problems developing a way to download these files. I've looked at the URLConnection API as well as other API's related to this. I can download regular text files with no problem, but when I need to download a jar file it just doesn't download. No error is thrown, the data just isn't transferred.

If anyone can point me in the right direction to successfully download jar files I would greatly appreciate it.

There is nothing special about JAR files themselves. Transfer it just like any other file (FileInputStream -> SocketOutputStream: SocketInputStream->FileOutputStream). The trick is to use the ClassLoader to link the classes into your running program after you have saved the JAR to disk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM