• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javac sourcepath classpath options

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
This is my first post!

I am having trouble using the sourcepath and classpath options in javac.

HelloWorld.java is in C:\Java.
If I go to C:\Java and use javac it compiles fine.

I am currently in the D:\Documents and Settings\Administrator directory. If I use
javac -classpath C:\Java HelloWorld.java

i am getting file not found : HelloWorld.java.

the same happens when I try javac -sourcepath C:\Java HelloWorld.java

but things work fine if I use the full path C:\Java\HelloWorld.java.

So, why isnt the classpath option working as it is supposed to?

thanks
Kevin
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

The classpath tells Java where to find Java class files. It does not tell Java where to find source files.

I'm not very familiar with the sourcepath option, but my understanding is that it's for specifying the location of .java source files that your main source file is dependent on -- not the location of the main file itself.

Does that make sense?
 
Swaminathan Raman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes...its kinda makes sense. So what would one do if the main source file is in a different directory?

I understand that it is easy to go to the source file directory in my case. But then there could be circumstances where one might want to compile source files in a different directory.

Is there a way out?
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been having exactly that problem, last night I started picking up builds even on files that were on a different root. That was because I had used settings/control panel/system/advanced/environment variables to set a long string containing every dir I could think of and then later was trying to work on a temporary version without disturbing the main build.

See: @argfiles which is likely more useful. This allows fast access to a configuration file that is stored with the sources.
reply
    Bookmark Topic Watch Topic
  • New Topic