Take the 2-minute tour ×  I have two java files in a directory,
neither of them are in a package. I want one of them to be able
to reference the other. What is the right way to do this?
Currently in Class A, I'm trying to reference class B, and
getting this error:  [javac] A.java:11: cannot find symbol
[javac] symbol  : constructor B(java.lang.String) [javac]
location: class B [javac]         B b = new B(path); [javac]
^  Nothing below worked:    • in A, doing "import B;"   • adding
"package myPackage;" to both A and B   share|improve this
question Could you post your javac command line? –  Andreas_D
Nov 25 '09 at 21:15 Could you post the code? There is a change
you don't have a constructor that uses a String –  OscarRyz Nov
25 '09 at 21:18 With both classes in the same directory, both
not declaring a package (i.e. both are in the default package)
add the directory that contains your source files to the javac
classpath. –  rsp Nov 25 '09 at 22:27 add comment  3 Answers  up
vote 3 down vote acce