java : cannot resolve symbol

I was compiling an JAVA ( 1.4 varsion )file and was getting the following error (about 100 times all are same). cannot resolve symbol
symbol  : class License
location: class test.App.Appli
            License  sellLicense = sell.getLicense();

I used

   run/cmd/cd D:...../javac

I had set the CLASSPATH variable, to the Classes folder of the java files I am presently running.

  Control panel/Settings/System/System Properties /Advanced/Environmental Variables/System Variables/ Add/CLASSPATH 

Should I use

How to solve the issue?

13.10.2009 21:48:55
Could we please see a sample of the code causing the errors?
jjnguy 13.10.2009 21:51:59
Well, not all 721 lines of it, but a sample.
jjnguy 13.10.2009 21:52:30
@vas: so you are putting the classes in a separate subtree, yes? In that case, you probably forgot to "cd" to the right place before compiling and didn't set -sourcepath. You need to do one or the other; see my answer.
Stephen C 13.10.2009 22:43:34

You need to set the CLASSPATH and make sure that you are in the correct directory.

Assuming that test.App.Appl is trying to reference test.App.License, the directory structure should be:


You should set $CLASSPATH to "/somedir", then change your current directory to /somedir and run the compiler as javac test/App/*.java; e.g.

$ export CLASSPATH="/somedir"
$ cd /somedir
$ javac test/App/*.java

You can also use the -cp command line option with the javac (and later the java) command, and you run the javac compiler from a different directory by using the -sourcepath option.

The other possibility is that the package for License is not test.App. If that is the case, you need to adjust the directory structure to match the package naming, and add an import statement to the Appl class.

EDIT: If you notice a build.xml or pom.xml (or possibly even a Makefile) in the source tree, you probably should not be using javac directly. A build.xml is for building using Ant, a 'pom.xmlis for Maven (or Ivy) and aMakefileormakefileis formake`.

13.10.2009 22:37:02
Setting the classpath environment variable is so last millenium... It's best not to set it at all, the current directory will be searched in any case.
Michael Borgwardt 13.10.2009 22:29:18
@Michael: actually, he should really be using Ant or Maven, so lets not split hairs.
Stephen C 13.10.2009 22:33:08

You are probably missing an import statement.

13.10.2009 21:53:01
I am trying to run an pre-existing code being used for production
vas 13.10.2009 22:03:52

It looks to me like you need to compile the class License with the class Appli. Take a look at the Javac Documentation for more details, but you can do something like the following:


If License is in a library, you will need to add the library to your compilation classpath. This is done with the -classpath flag:

javac -classpath "classpath"
13.10.2009 21:54:34
Should I use javac -classpath "classpath" every time i execute "javac"
vas 13.10.2009 22:04:42
@vas: yes ... or set $CLASSPATH, or use a build tool.
Stephen C 13.10.2009 22:45:07