• 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 access a package that we have created from another java application

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a package.Then i tried to acces a class inside that class by using import package.*;
But it is not accessible.But if we r giving it as pimport package.class it will work.
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kiran H Iyer:
I have created a package.Then i tried to acces a class inside that class by using import package.*;
But it is not accessible.But if we r giving it as pimport package.class it will work.


Have you set CLASSPATH correctly?
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kiran H Iyer:
I have created a package.Then i tried to acces a class inside that class by using import package.*;
But it is not accessible.But if we r giving it as pimport package.class it will work.


In order to find a class in a package, the jar file (package) must be on the classpath and the class you are trying to access in the package must be declared public.
How to put the jar on the classpath depends on your OS. In Windows, you can
set CLASSPATH=%CLASSPATH%;c:\myjars\newjar.jar
The jvm walks the classpath until it finds the package that you are talking about. Remember, too, that a jar is-a directory.
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic