File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes -sourcepath compilier option Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "-sourcepath compilier option" Watch "-sourcepath compilier option" New topic

-sourcepath compilier option

Gerry Boicourt

Joined: Feb 21, 2013
Posts: 1
I encountered this with a larger set of files but it boils down to this.
I am using the command line jdk to compile java code. Specifically javac -version = 1.7.0_05

In the current directory called src I have a simple java class file called

public class Earth {
public Earth() {
System.out.println("Hello from Earth!");

If I compile using "javac" it compiles fine.
Now I go "up" 1 directory by typing "cd .."
If I compile with the command "javac src\" again it compiles fine.

Here's the rub. If while still in the directory above src I use the -sourcepath option and type:
"javac -sourcepath src"

the compilier displays this message:
javac: file not found:
Usage: javac <options> <source files>
use -help for a list of possible options

I assume this is a case of dumb user error but I vexed if I can figure out what I'm doing wrong.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
Welcome to the Ranch
I am not sure that sourcepath is intended like that, but for finding classes which have already been compiled. But I am not sure. See whether the javac page makes it any clearer.
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Does your source file have a package statement? If yes, what is it?

~ Mansukh
I agree. Here's the link:
subject: -sourcepath compilier option
It's not a secret anymore!