This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes compilation problem using classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation problem using classpath" Watch "compilation problem using classpath" New topic

compilation problem using classpath

Mishaal Khan
Ranch Hand

Joined: Aug 21, 2008
Posts: 61
I am trying to compile a java program using JDK1.5 through console.In the bin dir of jdk I am giving command like:

c:\jdk1.5.0_05\bin>javac -classpath c:\source\

but it is giving message : no source files

I tried also with

c:\jdk1.5.0_05\bin>javac -sourcepath c:\source\

but same error message,any advice?
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

You need specify what you want to compile. This is not done using the classpath or sourcepath switch. You simple specify it:

You can also specify to compile all files in a directory using a wild character:

the -classpath and -sourcepath switches are used to specify dependencies. For example, if MyProg depended on JoesFancyBankCalculationTool.jar, I would specify that using the -classpath switch:

Also note that values in the classpath or sourcepath need to point either to a JAR file, or to a directory:

Information on the difference between the classpath and sourcepath switch can be found at
Mishaal Khan
Ranch Hand

Joined: Aug 21, 2008
Posts: 61
Thank you very much for the reply.Your suggestion worked!

Just a little bit more help I need:

If I want to run 'javac' from my directory i.e c:\myjavaprogs>javac

how can I set the environemnt variable at run time so that I need not to mention it everytime.

Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 378
search the Newbie Saloon (i.e. JavaRanch Beginners forum) with a few relevant keywords. There were a number of threads on this topic.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46424
Go to the Java Tutorials "common problems" page, and there is a link to instructions (for windows) for setting the PATH. You only need to set PATH. Follow those instructions to the letter.
I agree. Here's the link:
subject: compilation problem using classpath
It's not a secret anymore!