• 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

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



 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic