The classes belong to the same pkg. They are in the dir, name of the pkg.
- In general, how can classes access one another in the same pkg?
Error
javac PackTest.java
PackTest.java:8: cannot find symbol
symbol : class PriTest
location: class pacc.PackTest
System.out.println(new PriTest().getSaluto());
^
1 error
Classes in the PKG pacc
$ cat PackTest.java
package pacc;
import java.io.*;
public class PackTest
{
public static void main(String[] args)
{
System.out.println(new PriTest().getSaluto());
}
}
$ cat PriTest.java
package pacc;
public class PriTest
{
public PriTest(){}
private String saluto="SALUTO FROM PriTest";
public String getSaluto(){return saluto;}
}
PKG of the name of dir
$ find .. -type d -name "pacc"
../pacc
$ ls ../pacc
makefile PackTest.java PriTest.java
$ ls
makefile PackTest.java PriTest.java
Solved!
$ cat makefile
p:
javac ./pacc/PackTest.java
java pacc/PackTest
$ make p
javac ./pacc/PackTest.java
java pacc/PackTest
SALUTO FROM PriTest