Error in code when compiling [closed]

0

I created this code in Java and is giving error when compiling via CMD:

import java.io.*;
import jxl.*;
import java.util.*;
import jxl.Workbook;
import jxl.write.DateFormat;
import jxl.write.Number;
import jxl.biff.*;
import jxl.write.*;
import java.text.SimpleDateFormat;

class create {
    WritableSheet s = workbook.createSheet("Folha1", 0);
    WritableSheet s1 = workbook.createSheet("Folha1", 0);

    public static void main (String[] args){

        try{
            /*Seta o arquivo e suas instruções de execução*/
            String filename = "test.xls";
            WorkbookSettings ws = new WorkbookSettings();
            ws.setLocale (new Locale ("en", "EN"));
            WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws);
            writeDataSheet(s);
            writeImageShet(s1);

            /*Escreve e Fecha o Arquivo*/
            workbook.write();
            workbook.close();        

        }
        catch (IOException e){ 
            e.printStackTrace(); 
        }

        catch (WriteException e){ 
            e.printStackTrace(); 
        }
    }

    private static void writeDataSheet (WritableSheet s)throws WriteException; {{
        /* Formata a Fonte */
        WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD);
        WritableCellFormat cf = new WritableCellFormat (wf);
        cf.setWrap (true);

        /* Cria um Label e Escreve a Data em Uma Célula da Folha */
        Label l = new Label (0,0,"Data",cf);
        s.addCell(l);
        WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9);
        DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT);
        s.adCell(dt);

        /*Cria um Label e Escreve um Float Numver em Uma Célula da Folha*/
        l = new Label(2,0,"Float", cf);
        s.addCell(l);
        WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
        Number n = new Number(2,2,-3.1415926535, cf2);
        s.addCell(n);
        n = new Number(2,2,-3.1415926535, cf2);
        s.addCell(n);

        /* Cria um label e escreve um float number acima de 3 decimais em uma célula da folha*/
        l = new Label(3,0,"3dps",cf);
        s.addCell(l);
        NumberFormat dp3 = new NumberFormat("#.###");
        WritableCellFormat dp3cell = new WritableCellFormat(dp3);
        n = new Number(3,1,3.1415926535,dp3cell);
        s.addCell(n);

        /* Cria um label e adiciona 2 células na folha*/
        l = new Label(4, 0, "Add 2 cells",cf);
        s.addCell(l);
        n = new Number(4,1,10);
        s.addCell(n);
        n = new Number(4,2,16);
        f = new Formula(4,3, "E1+E2");
        s.addCell(f);

        /* Cria um Label e mulpiplica o valor de uma célula da folha por 2 */
        l = new Label(5,0, "Multiplica por 2",cf);
        s.addCell(l);
        n = new Number(5,1,10);
        s.addCell(n);
        f = new Formula(5,2, "F1 * 3");
        s.addCell(f);

        /* Cria um Label e divide o valor de uma célula da folha por 2.5 */
        l = new Label(6,0, "Divide por 2,5",cf);
        s.addCell(l);
        n = new Number(6,1, 12);
        s.addCell(n);
        f = new Formula(6,2, "F1/2,5");
        s.addCell(f);
        }
    }


    private static void WriteImageShet (WritableSheet s)throws WriteException; {{ 
        /* Cria um label e escreve uma imagem em uma célula da folha*/
        Label l = new Label(0, 0, "Imagem");
        s.addCell(l);
        WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png"));
        s.addCell(wi);

        /* Cria um label e escreve hyperlink em uma célula da folha*/
        l = new Label(0,15, "HiperLink");
        s.addCell(l);
        Formula f = new Formula(1, 15, "DevMedia(\"http://www.devmedia.com.br\", " + "\"Portal DevMedia\")");
        s.addCell(f);
        }
    }
}

I have read and reread this code and still the error saying that the variables l, f and all the line that has:

f = new Formula("Argumentos"); 
l = new Label("Argumentos");
WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png"));

In all of the 73 errors all of this type:

  

error: can not find symbol, error: missing method body or declare   abstract, error: Number is abstract; can not be instantiated

in the CMD appears:

Controle_Principal_CSG_teste.java:5: error: package jxl does not exist
import jxl.Workbook;
          ^
Controle_Principal_CSG_teste.java:6: error: package jxl.write does not exist
import jxl.write.DateFormat;
                ^
Controle_Principal_CSG_teste.java:7: error: package jxl.write does not exist
import jxl.write.Number;
                ^
Controle_Principal_CSG_teste.java:17: error: cannot find symbol
WritableSheet s = workbook.createSheet("Folha1", 0);
^
  symbol:   class WritableSheet
  location: class create
Controle_Principal_CSG_teste.java:18: error: cannot find symbol
WritableSheet s1 = workbook.createSheet("Folha1", 0);
^
  symbol:   class WritableSheet
  location: class create
Controle_Principal_CSG_teste.java:52: error: cannot find symbol
private static void writeDataSheet (WritableSheet s)throws WriteException; {{
                                    ^
  symbol:   class WritableSheet
  location: class create
Controle_Principal_CSG_teste.java:52: error: cannot find symbol
private static void writeDataSheet (WritableSheet s)throws WriteException; {{
                                                           ^
  symbol:   class WriteException
  location: class create
Controle_Principal_CSG_teste.java:114: error: cannot find symbol
private static void WriteImageShet (WritableSheet s)throws WriteException; {{
                                    ^
  symbol:   class WritableSheet
  location: class create
Controle_Principal_CSG_teste.java:114: error: cannot find symbol
private static void WriteImageShet (WritableSheet s)throws WriteException; {{
                                                           ^
  symbol:   class WriteException
  location: class create
Controle_Principal_CSG_teste.java:2: error: package jxl does not exist
import jxl.*;
^
Controle_Principal_CSG_teste.java:9: error: package jxl.write does not exist
import jxl.write.*;
^
Controle_Principal_CSG_teste.java:17: error: cannot find symbol
WritableSheet s = workbook.createSheet("Folha1", 0);
                  ^
  symbol:   variable workbook
  location: class create
Controle_Principal_CSG_teste.java:18: error: cannot find symbol
WritableSheet s1 = workbook.createSheet("Folha1", 0);
                   ^
  symbol:   variable workbook
  location: class create
Controle_Principal_CSG_teste.java:26: error: cannot find symbol
WorkbookSettings ws = new WorkbookSettings();
^
  symbol:   class WorkbookSettings
  location: class create
Controle_Principal_CSG_teste.java:26: error: cannot find symbol
WorkbookSettings ws = new WorkbookSettings();
                          ^
  symbol:   class WorkbookSettings
  location: class create
Controle_Principal_CSG_teste.java:28: error: cannot find symbol
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws);
^
  symbol:   class WritableWorkbook
  location: class create
Controle_Principal_CSG_teste.java:28: error: cannot find symbol
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws);
                            ^
  symbol:   variable Workbook
  location: class create
Controle_Principal_CSG_teste.java:29: error: non-static variable s cannot be referenced from a static context
writeDataSheet(s);
               ^
Controle_Principal_CSG_teste.java:30: error: non-static variable s1 cannot be referenced from a static context
writeImageShet(s1);
               ^
Controle_Principal_CSG_teste.java:44: error: cannot find symbol
catch (WriteException e){
       ^
  symbol:   class WriteException
  location: class create
Controle_Principal_CSG_teste.java:52: error: missing method body, or declare abstract
private static void writeDataSheet (WritableSheet s)throws WriteException; {{
                    ^
Controle_Principal_CSG_teste.java:57: error: cannot find symbol
WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD);
^
  symbol:   class WritavleFont
  location: class create
Controle_Principal_CSG_teste.java:57: error: cannot find symbol
WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD);
                      ^
  symbol:   class WritableFont
  location: class create
Controle_Principal_CSG_teste.java:57: error: cannot find symbol
WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD);
                                    ^
  symbol:   variable WritableFont
  location: class create
Controle_Principal_CSG_teste.java:57: error: cannot find symbol
WritavleFont wf = new WritableFont (WritableFont.ARIAL, 10, WritableFont.BOLD);
                                                            ^
  symbol:   variable WritableFont
  location: class create
Controle_Principal_CSG_teste.java:58: error: cannot find symbol
WritableCellFormat cf = new WritableCellFormat (wf);
^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:58: error: cannot find symbol
WritableCellFormat cf = new WritableCellFormat (wf);
                            ^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:62: error: cannot find symbol
Label l = new Label (0,0,"Data",cf);
^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:62: error: cannot find symbol
Label l = new Label (0,0,"Data",cf);
              ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:64: error: cannot find symbol
WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9);
^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:64: error: cannot find symbol
WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9);
                             ^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:64: error: cannot find symbol
WritableCellFormat cf1 = new WritableCellFormat(DateFormats.FORMAT9);
                                                ^
  symbol:   variable DateFormats
  location: class create
Controle_Principal_CSG_teste.java:65: error: cannot find symbol
DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT);
^
  symbol:   class DataTime
  location: class create
Controle_Principal_CSG_teste.java:65: error: cannot find symbol
DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT);
                  ^
  symbol:   class DateTime
  location: class create
Controle_Principal_CSG_teste.java:65: error: cannot find symbol
DataTime dt = new DateTime(0,1,new Date(), cf1, DateTime.GMT);
                                                ^
  symbol:   variable DateTime
  location: class create
Controle_Principal_CSG_teste.java:69: error: cannot find symbol
l = new Label(2,0,"Float", cf);
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:71: error: cannot find symbol
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:71: error: cannot find symbol
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
                             ^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:71: error: cannot find symbol
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
                                                ^
  symbol:   variable NumberFormats
  location: class create
Controle_Principal_CSG_teste.java:74: error: Number is abstract; cannot be instantiated
n = new Number(2,2,-3.1415926535, cf2);
    ^
Controle_Principal_CSG_teste.java:78: error: cannot find symbol
l = new Label(3,0,"3dps",cf);
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:80: error: cannot find symbol
NumberFormat dp3 = new NumberFormat("#.###");
^
  symbol:   class NumberFormat
  location: class create
Controle_Principal_CSG_teste.java:80: error: cannot find symbol
NumberFormat dp3 = new NumberFormat("#.###");
                       ^
  symbol:   class NumberFormat
  location: class create
Controle_Principal_CSG_teste.java:81: error: cannot find symbol
WritableCellFormat dp3cell = new WritableCellFormat(dp3);
^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:81: error: cannot find symbol
WritableCellFormat dp3cell = new WritableCellFormat(dp3);
                                 ^
  symbol:   class WritableCellFormat
  location: class create
Controle_Principal_CSG_teste.java:86: error: cannot find symbol
l = new Label(4, 0, "Add 2 cells",cf);
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:88: error: no suitable constructor found for Double(int,int,int)
n = new Double(4,1,10);
    ^
    constructor Double.Double(double) is not applicable
      (actual and formal argument lists differ in length)
    constructor Double.Double(String) is not applicable
      (actual and formal argument lists differ in length)
Controle_Principal_CSG_teste.java:90: error: no suitable constructor found for Double(int,int,int)
n = new Double(4,2,16);
    ^
    constructor Double.Double(double) is not applicable
      (actual and formal argument lists differ in length)
    constructor Double.Double(String) is not applicable
      (actual and formal argument lists differ in length)
Controle_Principal_CSG_teste.java:91: error: cannot find symbol
f = new Formula(4,3, "E1+E2");
        ^
  symbol:   class Formula
  location: class create
Controle_Principal_CSG_teste.java:95: error: cannot find symbol
l = new Label(5,0, "Multiplica por 2",cf);
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:97: error: no suitable constructor found for Double(int,int,int)
n = new Double(5,1,10);
    ^
    constructor Double.Double(double) is not applicable
      (actual and formal argument lists differ in length)
    constructor Double.Double(String) is not applicable
      (actual and formal argument lists differ in length)
Controle_Principal_CSG_teste.java:99: error: cannot find symbol
f = new Formula(5,2, "F1 * 3");
        ^
  symbol:   class Formula
  location: class create
Controle_Principal_CSG_teste.java:103: error: cannot find symbol
l = new Label(6,0, "Divide por 2,5",cf);
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:105: error: Number is abstract; cannot be instantiated
n = new Number(6,1, 12);
    ^
Controle_Principal_CSG_teste.java:107: error: cannot find symbol
f = new Formula(6,2, "F1/2,5");
        ^
  symbol:   class Formula
  location: class create
Controle_Principal_CSG_teste.java:114: error: missing method body, or declare abstract
private static void WriteImageShet (WritableSheet s)throws WriteException; {{
                    ^
Controle_Principal_CSG_teste.java:118: error: cannot find symbol
l = new Label(0, 0, "Imagem");
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:120: error: cannot find symbol
WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png"));
^
  symbol:   class WriteableImage
  location: class create
Controle_Principal_CSG_teste.java:120: error: cannot find symbol
WriteableImage wi = new WriteableImage(0, 3, 5, 7, new File ("imagem.png"));
                        ^
  symbol:   class WriteableImage
  location: class create
Controle_Principal_CSG_teste.java:124: error: cannot find symbol
l = new Label(0,15, "HiperLink");
        ^
  symbol:   class Label
  location: class create
Controle_Principal_CSG_teste.java:126: error: cannot find symbol
f = new Formula(1, 15, "DevMedia(\"http://www.devmedia.com.br\", " + "\"Portal DevMedia\")");
        ^
  symbol:   class Formula
  location: class create
61 errors
    
asked by anonymous 20.10.2017 / 18:35

1 answer

2

Well, look what the error says:

  

abstract, error: Number is abstract; can not be instantiated

What is happening there is a conflict between classes jxl.write.Number and java.lang.Number .

I think you want to use the first one, because it would not even make sense to use the other one since it's an abstract class

.

As all java.lang classes are implicitly imported throughout the project, you will need to write the full name of the jxl.write class.

For example:

n = new Number(2,2,-3.1415926535, cf2);
    
20.10.2017 / 20:05