public void downloadJarFromJenkins(String urlPrefix, String localPath) {
		InputStream input = null;
        FileOutputStream writeFile = null;

        try {
        	String path = getJenkinsRelativePath(urlPrefix);
        	URL url = new URL(urlPrefix+"lastStableBuild/artifact/"+path);
        	System.out.println(url);
            URLConnection connection = url.openConnection();
            int fileLength = connection.getContentLength();

            if (fileLength == -1) {
                System.out.println("Invalide URL or file.");
                return;
            }

            input = connection.getInputStream();
            String fileName = url.getFile().substring(url.getFile().lastIndexOf('/') + 1);
            writeFile = new FileOutputStream(localPath+'/'+fileName);
            byte[] buffer = new byte[1024];
            int read;

            int bytesDownloaded = 0;
            setProgress(0);
            while ((read = input.read(buffer)) > 0) {
                writeFile.write(buffer, 0, read);
                
                bytesDownloaded += read;
                setProgress((int) ((float)bytesDownloaded/fileLength*100));
            }
            writeFile.flush();
        } catch (IOException e) {
            System.out.println("Error while trying to download the file.");
            e.printStackTrace();
        } finally {
            try {
                writeFile.close();
                input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
	}