aspose file tools*
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
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: 350
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: 39436
    
  28
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: http://aspose.com/file-tools
 
subject: compilation problem using classpath