0

I have problems with these methods.

The error is:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: pkgModelo.AnalizadorLexico: method <init>()V not found

The classes are:

Class frmAnalizador:

package pkgVista;
import pkgModelo.AnalizadorLexico;

public class frmAnalizador extends javax.swing.JFrame {
    AnalizadorLexico alexico;
    String linea;
    JFileChooser abrirArchivo;

    public frmAnalizador() {
        initComponents();
        alexico = new pkgModelo.AnalizadorLexico();
    }
}

In object alexico show the exception.

Class AnalizadorLexico:

package pkgModelo;

import java.io.FileInputStream;

public class AnalizadorLexico implements AnalizadorLexicoConstants {

    public AnalizadorLexico() {
    }

    public static void principal(FileInputStream file) throws ParseException {
        try {
            AnalizadorLexico analizador = new AnalizadorLexico(file);
            analizador.Algoritmo();
            System.out.println("El analizador l\u00e9xico ha compilado correctamente");
        }
        catch(ParseException e) {
            System.out.println("Hay errores: " + e.getMessage());
        }
    }
}

1 Answer 1

1

Here in this line AnalizadorLexico analizador = new AnalizadorLexico(file); you passed file object as a parameter where as your class AnalizadorLexico has not any kind of parameterized constructor so you have to make one more constructor which has a parameter of FileInputStream.

public AnalizadorLexico(FileInputStream file){

     //Your Code
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.