• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

classpath

 
Ranch Hand
Posts: 91
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
consider the directory structure:

/(root)
|
|
|---dirA
|
|----dirB
|
|----dirC


classpath is:

-cp /dirB:/dirA/dirB/dirC

the statement in the book regarding the above is given as follows: specifically only dirC will be searched, regardless of the current directory. then is the classpath given valid?

Can anyone please explain me absolute paths vs relative paths
 
Komal Arora
Ranch Hand
Posts: 91
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
umm the directory structure did not come out properly

it's Root which contains dirA which contains dirB which contains dirC
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the below directory structure:
/
+Project
++src
++classes

Say you are in the directory " /Project/src".
There are 2 ways to compile.
Using absolute path:
javac -cp /Project/classes filename.java
Using relative path:
javac -cp ../classes filename.java

In the later case java compiler searches for classes folder under parent directory.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Given a classpath : -cp /dirB:/dirA/dirB/dirC

If dirC has a subdirectory named "dirD", will classes in dirD directory be found thanks to this classpath?

Thanks!
 
Bartender
Posts: 4100
63
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Komal Arora wrote:...the statement in the book...


Please QuoteYourSources when posting.
 
John Eipe
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

Here is an example:

I have the following dir structure
/JSpace/t/tt/in.java
/JSpace/out.java



How would i compile and run?

Currently i'm in /JSpace
To compile
:~/JSpace$ javac ./t/tt/in.java
:~/JSpace$ javac -cp ./t/tt out.java
To run
:~/JSpace$ java -cp ./t/tt:. out

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!