Erro na execução java.lang.NullPointerException

Olá a todos,

Estou tentando executar esse código no netbeans:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Acesso;

import java.awt.*;
import java.awt.print.*;
import java.io.*;
import java.net.*;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import java.lang.*;

public class Acesso implements Printable {

    //cria as variaveis de fontes
   public static final int DEFAULT_FONT_SIZE = 12;
   public static final String DEFAULT_FONT_NAME = "Serif";

   //impressora
   private PrinterJob job;
   private String typeName;
   private int typeSize;
   private Font typeFont;
   private Font typeFontBold;
   private String [] header;
   private String [] body;

     public Acesso() {
       this(DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE);
   }

   public Acesso(String name, int size)
   {
       if (size < 3 || size > 127) {
           throw new IllegalArgumentException("Type size out of range");
       }
       typeName = name;
       typeSize = size;
       typeFont = new Font(typeName, Font.PLAIN, typeSize);
       typeFontBold = new Font(typeName, Font.BOLD, typeSize);
       job = null;
   }

        public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
        {
           if (pageIndex != 0) {
           return NO_SUCH_PAGE;
       }
       FontMetrics fm;
       graphics.setFont(typeFont);
       graphics.setColor(Color.black);
       fm = graphics.getFontMetrics();
     
       int i;
       double x, y;
       x = pageFormat.getImageableX();
       y = pageFormat.getImageableY() + fm.getMaxAscent();

       // Cria cabeçalho
       if (header != null) {
           graphics.setFont(typeFontBold);
           for(i = 0; i < header.length; i++) {
               graphics.drawString(header[i],(int)x, (int)y);
               y += fm.getHeight();
           }
       }

       // parte da impressão
       if (body != null) {
           graphics.setFont(typeFont);
           for(i = 0; i < body.length; i++) {
               graphics.drawString(body[i],(int)x,(int)y);
               y += fm.getHeight();
           }
       }

       return PAGE_EXISTS;
   }

   protected void init() {
       job = PrinterJob.getPrinterJob();
   }

      public int getCharsPerLine() {
       if (job == null) {
           init();
       }
       PageFormat pf;
       pf = job.defaultPage();
       double width = pf.getImageableWidth();
       double ptsize = typeFont.getSize();
       double ptwid = ptsize * 3 / 4;
       double cnt = (width / ptwid);
       return (int)(Math.round(cnt));
   }

        public boolean doPrint(String [] header, String [] body, boolean interactive)
       throws PrinterException
   {
       if (job == null) {
           init();
       }
       if (interactive) try {
           if (job.printDialog()) {
               
           } else {
               
               return false;
           }
       } catch (Exception pe) {
           System.err.println("Não abriu a a janela de dialogo da impressora");
           // assume user wants to print anyway...
       }

       job.setPrintable(this);
       this.header = header;
       this.body = body;
       job.print();
       job = null;  
       return true;
   }
        
public static final long TEMPO = (100 * 60);
    public static void main(String[] args) throws IOException {
       BufferedReader br;
       final java.util.List lines;
       final Acesso tp = null;

       lines = new java.util.ArrayList();
       Timer timer = null;
         if (timer == null) {
             timer = new Timer();
             TimerTask tarefa = new TimerTask() {
             public void run() {

try{
    URL amplus = new URL("http://192.168.0.1/academico/desenvolve/fotos/dados.txt");
    URLConnection amp = amplus.openConnection();
    amp.setConnectTimeout(7000);
    amp.connect();
    BufferedReader in = new BufferedReader(new InputStreamReader(amp.getInputStream()));

           String line;
           for(line = in.readLine(); line != null;
               line = in.readLine())
               {
                   lines.add(line);
               }
           in.close();
           if(lines.isEmpty()){
            System.out.println(lines);
           }else{
           String [] headers = new String[1];
           headers[0] = "Impressão Biblioteca";
           String [] body = new String[lines.size()];
           for(int ix = 0; ix < lines.size(); ix++) {
               body[ix] = (String)(lines.get(ix));
           }

           try {
           
                    boolean didit = tp.doPrint(headers, body, false); // aqui diz que a variavel não é usada

               // System.out.println(lines);

                HttpClient client = new HttpClient();
                HttpMethod method = new GetMethod("http://192.168.0.1/academico/desenvolve/fotos/delete_dados.php");
                client.executeMethod(method);

           } catch (PrinterException ex) {
                Logger.getLogger(Acesso.class.getName()).log(Level.SEVERE, null, ex);
           }

            }
            } catch (MalformedURLException me) {
           // System.out.println("MalformedURLException: " + me);
            } catch (IOException ioe) {

            //System.out.println("IOException:1" + ioe);
            }
                 }  //fechou run

             };  // fechou TimerTask

             timer.scheduleAtFixedRate(tarefa, TEMPO, TEMPO);
         }
         }

    }

e ta me dando o seguinte erro:

Exception in thread "Timer-0" java.lang.NullPointerException
        at Acesso.Acesso$1.run(Acesso.java:169)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)

quando eu clico em cima da Acesso.java:169 vai para essa linha:

 boolean didit = tp.doPrint(headers, body, false);

e diz que a variavel não esta sendo usada.

Alguem pode me dá uma ajuda para alguem que ta começando no JAVA.

Agradeço qualquer ajuda

Antonio

Olá

Você está falando que “tp” é igual a nulo.

final Acesso tp = null; 
[quote]

Você tem um objeto do tipo Acesso que aponta para lugar nenhum, ou seja, não tem a instância de um objeto, por isso o erro.

Tente deixar assim:

final Acesso tp = new Acesso();

[code]

Dá uma pesquisada na net sobre o erro p voce entender melhor.