• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Classpath Question

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I apologise if this has been asked and answered previously but I haven't been able to find an existing forum answer to such a question.

I have the following structure

C:\a\A.java
C:\b\B.java

I compile these source files and the following structure results;

C:\a\A.class
C:\b\B.class

The A class creates an instance of B then calls B and B prints out "B"

I run the program as follows;



All fine and well. It works as expected. Then I decided to play around with the -classpath option as follows;



All fine and well. It works as expected. Then I run;



An exception is thrown. No problem, this is expected. I then run;



This is my question, why does this run? I have used the same classpath C:\f; but this time I have placed a ";" at the end of the classpath. I have not placed a period "." after the ";" to denote the current directory as part of the classpath. Sun states that;

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.



I haven't included the "." in my classpath but for some reason my classes are being found. Am I missing something here. Does the ".' automatically get appended to the classpath if the classpath ends in ";".

Any assistance will be greatly appreciated.

Thanks



 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic