Import & # 8594; 'cannot find character' | full name & # 8594; excellent

I have an inner class that extends AbstractTableModel.

import javax.swing.table.AbstractTableModel; public class MyClass extends MyAbstractClass { ... public static class MyTableModel extends AbstractTableModel { } ... } 

The compiler gives me the following error.

 ...\MyClass.java:190: error: cannot find symbol public static class MyTableModel extends AbstractTableModel { ^ symbol: class AbstractTableModel location: class MyClass 

When it changes

 MyTableModel extends AbstractTableModel 

to

 MyTableModel extends javax.swing.table.AbstractTableModel 

everything is working fine.

I use Gradle to create a project. Before switching to Gradle, I used Eclipse to create the project. I had no problem with Eclipse, an error occurs if I create using Gradle.

Do you have an idea what could be causing this strange behavior?

+5
source share
1 answer

The error was caused by my import order. MyTableModel contains the MyTableListener interface, which is also imported by MyClass.java.

 import MyClass.MyTableModel.MyTableListener; ... import javax.swing.table.AbstractTableModel; ... public class MyClass extends MyAbstractClass { ... public static class MyTableModel extends AbstractTableModel { public interface MyTableListener { public void entryChanged(); } ... } ... } 

When I put an import of MyTableListener before importTableModel imports Gradle, I cannot find the symbol error.

When I add AbstractTableModel import before importing MyTableListener, everything works fine.

So far, so good, but why is import order not a problem when creating with Eclipse ?!

+4
source

Source: https://habr.com/ru/post/1205478/


All Articles