I'm just learning Java, and can't figure out why I'm getting an error on this. I've read several tutorials, and it seems like everything is OK, but obviously it must not be. The file2.java file won't compile, generating a "Cannot Find Symbol" error. Does anyone see what I'm doing wrong here? Thanks!
I've created these two files on my desktop, and added /home/brad/Desktop to my $CLASSPATH. (I'm using Linux). I compile file1.java first, which works fine. Then I try to compile file2.java, which doesn't compile.
Thanks!!! That worked perfectly.
Do you know if there is any alternative to modifying the classpath when working with multiple classes? Is there any other way to tell the java compiler where to look? My goal with this question is to avoid the need for someone else to modify their CLASSPATH if I send them my java files. Thanks for your help!
Generally you don't want to use the CLASSPATH environment variable at all. Both the Java compiler and the runtime accept a -classpath command-line switch; rather than setting CLASSPATH, you can and should always use the -classpath argument instead:
Thanks for the tip. I took out the package names. I only had them in there because a lot of the tutorials I read started with "Assuming the files are in the same package..." Everything is working perfectly now. Thanks everyone!