Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Classpath

 
Ferwed Kondos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following 2 files in these 2 packages:

Now I want to compile class Child, consider these 2 packages are contained in a directory called "Test" I simply do this in command line:
cd Test
javac pack2\Child.java

My question, shouldn't I be using -classpath option to locate Parent.java during compilation, same when running to locate Parent.class.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ferwed Kondos:
...shouldn't I be using -classpath option to locate Parent.java during compilation, same when running to locate Parent.class.

If no classpath is specified, Java's default is to look in the current directory. Since this is where pack1.Parent is located, it should work without explicitly specifying a classpath.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!