• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why do we use classpath command(-cp) while running a java application?(Chapter 1-OCA8)

Saumyaraj Zala
Ranch Hand
Posts: 75
AngularJS Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I was trying to import a package that was not on the current directly and compiler complained saying "package not found"
Current directly where Demo.java is present = C:/temp
Directly where org.open was present = C:

Then I tried command using -classpath option  i.e javac -classpath c: com\hello\Demo.java and the things worked fine.

Now I am wondering why -cp option is used at runtime as mentioned in chapter 1 of OCA8 when compiler checks for the imports at compile time itself?

Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!