HI i have 3 java files
a.java
b.java
c.java
I managed to generate .class files for both a and b using
javac example/a.java
javac example/b.java
but when i do the same for c.java I get the error
error: cannot find symbol b and c
Any suggestions on how i could solve this problem ?
All the java files are in the same folder
You have to have classes
aandbin your classpath when you try to compile classc. This allows the compiler to verify that they exist, figure out what methods they have, etc.javacis pretty sensitive to package names and classpaths. The easiest thing to do is to compile all three at the same time like sojavac example/a.java example/b.java example/c.java.If you go to the parent directory of example (let’s call it
src), then you can run the following:The reason you have to do it this way is because your classes have their packages listed as
example. Because of your package name,javacis looking for theexampledirectory in its classpath, where it expects to finda.classandb.class.