• 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

doubt in classpath ?

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please refer the link http://docs.oracle.com/javase/6/docs/technotes/tools/findingclasses.html. the given link says


By default, javac and javadoc search the user class path for both class files and source code files. If the -sourcepath option is specified, javac and javadoc search for source files only on the specified source file path, while still searching the user class path for class files.




to test this, i created source code file as below:




i put the above file in c:\users\g\world directory. then i set the classpath as set classpath=c:\users\g\world. then i ran javac from the d: root drive as d:\> javac HelloWorld.java. according to above link javac by default searches user classpath for source file and class file so it should have compiled . what is the reason ?
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it works that way. When you write the command javac HelloWorld.java, the HelloWorld.java file should be in the current directory where you run the javac command. If lets say your world.HelloWorld class use a class globe.MyGlobe[tt], then the [tt]globe\MyGlobe.java file will be searched in the classpath. Even in that case your classpath should contain the parent directory of globe directory (so in your case your classpath should contain C:\users\g not C:\users\g\world)...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic