This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 9044
    
  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: 24183
    
  34

-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: 9044
    
  10
Ah, I see. Thanks, Ernest.
 
 
subject: javac sourcepath
 
Similar Threads
Need help in compiling programs
javac changes camelCase to lower case
Ant building error
ant javac command changes case(s)
Problems compiling packages #2 with JSP