This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation problem using classpath" Watch "compilation problem using classpath" New topic
Author

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\myprog.java

but it is giving message : no source files

I tried also with

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

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 http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#searching
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 myprog.java

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

Thanks.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
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
Sheriff

Joined: Oct 13, 2005
Posts: 37902
    
  22
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.
 
wood burning stoves
 
subject: compilation problem using classpath
 
Similar Threads
AdviceClient compiler error in HFE
java 7: cannot find symbol
hello world code
Eclipse and Ant Problem
Javac error...