Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • 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
Hi,

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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic