Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation problem using classpath

 
Mishaal Khan
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50217
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic