This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Package import issue.

 
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers, I have a base folder on my Desktop called access modifers in that folder I have two sub folders called building and library, folder building have a public class  FlatHouse defined as

and folder library have a public class TextBook defined as


The issue is, if I try to compile any of the class, for example the class in the package building
I get error package library does not exist.
Please I do not know what I am over looking, or doing wrongly, I need some help!!!
packageError.PNG
[Thumbnail for packageError.PNG]
 
Marshal
Posts: 8971
646
Mac OS X Spring VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In short, you need to specify the classpath where Java supposed to look for imported classes. As you see error message suggests, that it can't find TextBook. It is because it doesn't know how to find a package "library".

Give a shot yourself first after researching a bit how to set the classpath during the compile and later run. If there are more locations to specify, classpath separators differ from OS to OS, or more precisely, from Windows to UNIX-like OS.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kelvin Okornoe wrote:Please I do not know what I am over looking, or doing wrongly, I need some help!!!


An excellent explanation about how to compile classes within different packages can be found in this thread. Definitely worth reading!
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic