Glacing over your code I see the method
/**
* Download the client.
*/
static void downloadFile() {
try {
URL url2 = new URL("http://lostredemption.com/LostRedemption.jar");
InputStream in = new BufferedInputStream(url2.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n = 0;
while (-1 != (n = in .read(buf))) {
out.write(buf, 0, n);
}
out.close();
in .close();
byte[] response = out.toByteArray();
FileOutputStream fos = new FileOutputStream(directory);
fos.write(response);
fos.close();
//openDownloadClient();
}
catch (IOException e) {
JOptionPane.showMessageDialog(null, "Unable to download latest client. Please check your internet connection and try again.", "Error", JOptionPane.ERROR_MESSAGE);
closeProgram();
}
}
Nice job catching the exception and showing the user but you never told yourself what the error was. This is why most programs have error logs!
Just by simply putting a System.out.println(e);
I can see this error message:
java.io.IOException: Server returned HTTP response code: 403 for URL: http://lostredemption.com/LostRedemption.jar
Great now I search Java URL open Stream 403
in Google and voila top result on Google will yeild: Server returning 403 for url openStream() the first answer in that SO question will get your program working
URL url2 = new URL("http://lostredemption.com/LostRedemption.jar");
HttpURLConnection httpcon = (HttpURLConnection) url2.openConnection();
httpcon.addRequestProperty("User-Agent", "Mozilla/4.0");
ReadableByteChannel rbc = Channels.newChannel(httpcon.getInputStream());
FileOutputStream fos = new FileOutputStream(directory);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
Remember always look at your error messages before you do any research.