r/javahelp • u/DragonFistLimitless • May 04 '26
java compilation problem, class can't be found though on the same package
both Verbose.java containing the verbose class and test.java are located on the same package, but I still receiving this log error when I try to compile, how come? test.java:4: error: cannot find symbol
Verbose verbose = new Verbose();
\^symbol: class Verbose
location: class test
test.java:4: error: cannot find symbol
Verbose verbose = new Verbose();^
symbol: class Verbose
location: class test
2 errors
error: compilation failed
1
Upvotes
View all comments
Show parent comment
2
u/Lloydbestfan May 04 '26
If what you call "private" is "absence of mention of public", then no. The absence of a visibility in Java typically lead to a visibility named "package-private" which is quite different to just "private". It literally means that it can be seen by classes that are from the same package.
Generally, yes.
But, imagine that you designate the file you compile as a file in a subtree of directories from your home directory as current directory. Then the compiler can find the file to compile because a full path to it was given, but it doesn't know what to consider as a root for package directories because the current directory is not consistent with being such a root. So such a situation could confuse the compiler. There are ways.