• 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

Significance of dot(.) in classpath

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"The way to tell java or javac to search in current directory is to add a dot(.) to classpath".

Can any one explain what does this exactly mean?
According to i read earlier , the Following code:

> -classpath /com/foo/acct: /com/foo

Here the directory /com will NOT be searched .

I grasped that by using dot(.) we can refer to /com as follows :

-classpath /com/foo/acct:/com/foo.
Am i right? Kindly clear my confusion ..
I shall gratefull to you

 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your PATH and CLASSPATH are lists of directories - nothing more. they are separated in the list by a semicolon (on windows).

Usually, when you are working in java, your .java files are in a different directory than where your java.exe (or other executable depending on your OS) lives. so you will be in C:\home\fred\java\source. If you set up your PATH correctly, the OS will search all the directories in your path to see if that .exe is in one, and if so, it will run it.

CLASSPATH works in a similar fashion, except it is used by the JVM to find where your .class files are. so no matter what directory you are sitting in, if you type "java fred", the JVM will search all the directories listed in your CLASSPATH to find the "fred.class" file.

You can put a dot in your classpath to tell the JVM to always look in whatever directory you are currently sitting in when you call java. so if you are here:

c:\home\fred\java\classes, the JVM will look there, so long as you have a dot in your classpath. Note that if you don't have a classpath defined at all, the jvm looks in the current directory by default.

so, if you don't have a CLASSPATH defined (which is usually recommended for beginners), or if you have a dot in your CLASSPATH, you'll probably be fine.
 
Greenhorn
Posts: 18
Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. is a convention in linux for present directory.
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Puneet Soni wrote:. is a convention in linux for present directory.


it's not just linix
 
reply
    Bookmark Topic Watch Topic
  • New Topic