• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to work with packages?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i cant understand if i made my package and i want to import a class from that which is not in my package how to do it. i mean i cant figure out how packages work
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,

Consider the packages as folders.

I have a package com.deepak.test that means I have a folder structure like com/deepak/test
I also have one more package com.deepak.test1 that means I have a folder structer like com/deepak/test1

If I have a class TestClass in both packages and I want to call this class from some other package.

When I want to import a TestClass from com/deepak/test1 folder. It is almost like giving the path of the class. JVM will search the same path in its classpath.
I'll mention "import com.deepak.test1.TestClass"

or if I want the TestClass in com/deepak/test then I'll mention as "import com.deepak.test.TestClass"
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at Creating and Using Packages, where it's all explained step by step.
 
deepak kushwaha
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the help. sorry for my late response, my net connection was lost for 5 days. thankyou
 
reply
    Bookmark Topic Watch Topic
  • New Topic