• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

Ranch Hand
Posts: 75
Eclipse IDE AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

    Bookmark Topic Watch Topic
  • New Topic