• 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

compilation problem using classpath

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic