File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes javac sourcepath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javac sourcepath" Watch "javac sourcepath" New topic
Author

javac sourcepath

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
javac -d C:\projectsCC\ETL\xtract\adm\common\classes -sourcepath C:\projectsCC\ETL\xtract\adm\common\src com\ibm\esmrt\adm\common\Conductor.java

I expect that if I'm sitting in a directory
C:\java
and type this command, it will look in C:\projectsCC\ETL\xtract\adm\common\src for com\ibm\esmrt\adm\common\Conductor.java and I'll find the Conductor.class file here C:\projectsCC\ETL\xtract\adm\common\classes\com\ibm\esmrt\adm\common\Conductor.class

but
I'm getting
error: cannot read: com\ibm\esmrt\adm\common\Conductor.java
(it doesn't work with dots either
error: cannot read: com.ibm.esmrt.adm.common.Conductor.java)

What am I doing wrong? How can I compile this without going into the src directory?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

-sourcepath tells javac where to find other source files, besides the ones you specify on the command line. Those you have to be explicit about. So

javac -d C:\projectsCC\ETL\xtract\adm\common\classes -sourcepath C:\projectsCC\ETL\xtract\adm\common\src C:\projectsCC\ETL\xtract\adm\common\src\com\ibm\esmrt\adm\common\Conductor.java

will work, and it will find any source files that Conductor.java depends on. Without -sourcepath, this command would fail unless Conductor.java had no dependencies.


[Jess in Action][AskingGoodQuestions]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Ah, I see. Thanks, Ernest.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac sourcepath
 
Similar Threads
Need help in compiling programs
ant javac command changes case(s)
javac changes camelCase to lower case
Ant building error
Problems compiling packages #2 with JSP