views:

44

answers:

2

This has been frustrating me intensely.

I am trying to compile my source code from the Windows 7 command prompt. I have added the directory in which my *.java file is located to the classpath. Yet, I still get this error:

C:\Users\Alex>javac HelloThere.java javac: file not found: HelloThere.java Usage: javac use -help for a list of possible options

I'm very confused as to why this happens because if I navigate to the folder where this file is located, it will compile. However, this is not a satisfactory solution since I intend on compiling JUnit tests directly from the command line as well...

Other solutions I have attempted:

C:\Users\Alex>javac -classpath "C:\Users\Alex\AndroidProject\UnitTest\src" Hello There.java javac: file not found: HelloThere.java Usage: javac use -help for a list of possible options

I do not think this has ANYTHING to do with typos...

Image showing what I'm doing...

http://yfrog.com/7gpic2uhp

Please tell me I'm just doing something stupid...because I have no idea why this will not work...

+1  A: 

The CLASSPATH variable is not used by javac to find where your source code lives. Use the -sourcepath arg to javac instead.

Save yourself a lot of time and manual typing and use a build tool like Apache Ant or Maven.

matt b
Or just save yourself a lot of time AND trouble by shortening that list down to Ant. :)
Crusader
+1  A: 

You don't want to use classpath, that tells the compiler where to find externally referenced .class files used by your file. You want to use -sourcepath which tells javac where your .java files may be hiding.

RD