-2
Well friends, I was using two classes:
Funcionario.java
(Class 1, from the directory /home/lcs/Documentos/java/exercicio3
) and UtilizandoFuncionario.java
(Class 2, from the directory /home/lcs/Documentos/java
).
So far so good, I used the class 2 command import exercicio3.Funcionario;
and it worked fine, but when I put class 2 in the directory /home/lcs/Documentos/java/exercicio4
the command stopped working and started to give error in the terminal.
I would like to know how to use the Work class in the Using class /home/lcs/Documentos/java/exercicio4
?
package exercicio3;
public class Funcionario {
private int matricula;
private double salario;
//RESTO DO CÓDIGO ...
}
package java;
import exercicio3.Funcionario;
public class UtilizandoFuncionario {
public static void main(String ... args){
//RESTO DO CÓDIGO ...
}
}
I used to compile:
Documentos/java/exercicio4$ javac UtilizndoFuncionario.java
sends the directory structure, import code and your call to the console.
– ulima69
Have you changed your import? You have to change it tb, if you changed the address of your files...
– DiegoSantos
Sorry it takes... The directory for the Funcionario.java class is: /home/lcs/Documents/java/exercicio3 package exercicio3; public class Funcionario{ private int matricula; private double salario; //REST OF THE CODE ... } While the Using class.java was in: /home/lcs/Documents/java package java; import exercicio3.Funcionaio; public class Utilisingwork{ public Static void main(String ... args){ //REST OF THE CODE ... } }
– lcsmarlon
In the terminal I used the following command, with the terminal inside the directory: lcs@LcsMarlon:~/Documents/java$ javac Usefull.java Compiles everything right, but when I changed the file Usefull.java to the other directory: /home/lcs/Documents/java/exercicio4 Started to give error when I typed in the terminal, in the new directory of course: lcs@LcsMarlon:~/Documents/java/exercicio4$ javac Utilizndofuncionaio.java Presented error: Utilizandofuncionario.java:1: error: package exercicio3 does not exist import exercicio3.Funcionario; 1 error @ulima69
– lcsmarlon
How would I change my import @Diegosantos??? I tried, but I can’t manage!
– lcsmarlon