1
I have a problem with import
of a package that I created in Java, the project directory tree is this:
.
├── CsvFiles
│ ├── 01
│ ├── 01.zip
│ ├── ALPOO_GRADUACAO_2018.csv
│ ├── ALPOO_GRADUACAO_2019.csv
│ ├── ALPOO_POS_GRADUACAO_2019.csv
│ ├── alunos.csv
│ ├── cursos.csv
│ └── LPOO_GRADUACAO_2019.csv
├── LICENSE
└── src
├── entidades
│ ├── Aluno.class
│ ├── Aluno.java
│ ├── Curso.class
│ ├── Curso.java
│ ├── Nota.class
│ ├── Nota.java
│ ├── Rendimento.class
│ └── Rendimento.java
├── io_handle
│ ├── handleCSV.java
│ ├── Menu.class
│ └── Menu.java
└── tests
├── ALPOO_GRADUACAO_2019.csv
├── test.class
└── test.java
I’m creating a package by directory, for example within entidades
, all the files .java
has in its first line the code:
package entidades;
In the archive handleCSV.java
, I import some classes from the package entidades
, and declare his package with the following code:
package io_handle;
import entidades.Nota;
import entidades.Aluno;
But when I compile the Nota.java
, get the bug:
╰──➤ javac Nota.java
Nota.java:3: error: cannot find symbol
import entidades.Aluno;
^
symbol: class Aluno
location: package entidades
Nota.java:9: error: cannot find symbol
public class Nota extends Aluno {
^
symbol: class Aluno
2 errors
And consequently when I compile handleCSV.java
get the bug:
╰──➤ javac handleCSV.java
handleCSV.java:21: error: package entidades does not exist
import entidades.Nota;
^
handleCSV.java:22: error: package entidades does not exist
import entidades.Aluno;
^
handleCSV.java:23: error: package entidades does not exist
...
21 errors
But when I compile all the files together with the command:
╰──➤ javac Aluno.java Curso.java Nota.java Rendimento.java
I don’t get any error. But the error in the build of handleCSV.java
continues.
About the files themselves, Curso.java
, Aluno.Java
, Rendimento.java
, handleCSV.java
and Menu.java
are initiated as follows:
public class [Nome da classe] {
...
}
Already Nota.java
is started as follows:
public class Nota extends Aluno {
...
}
What is it, Maven? The
src
is to stay out of the package name. You may have found some way to solve it, but it’s wrong. You have to fix the mistake you made when you weren’t using thesrc
, I don’t know if it’s classpath setting or what.– Piovezan
Problem XY. Edit the question by putting the original problem. I voted to close as unclear.
– Piovezan
Could you check if the Student class is being declared public? in case: public class Student {<Class-content>} Because if not, actually the class reference will not be captured by the compiler.
– Hitallo Cavalcanti da Silva