• 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

Strange prob with Library

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all Hi everybody,

I'm fighting this problem the whole day now, so please help me or I get crazy!

I'm using Netbeans IDE 5.0 and want to import classes from the following file:
ftp://ftp.unidata.ucar.edu/pub/netcdf-java/v2.2.16/netcdf-2.2.16.jar

So I went to >Tools>Library Manager and added the file in the Classpath of a new Library
Then I right clicked on my current Projects Libraries Folder >add Library and added the new Library.

And something did happen. The Editor now knows a new folder ucar with lot of classes, but trying to actually use them (import ucar.* I get the massage:
"package ucar does not exist"

What is my mistake?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by J. Bisa:
... The Editor now knows a new folder ucar with lot of classes, but trying to actually use them (import ucar.*;) I get the massage:
"package ucar does not exist"

What is my mistake?


Welcome to JavaRanch!

You cannot import "subpackages" using the wildcard asterisk (*). You need to specify the complete package name, and then you can use the wildcard to indicate all types within that package. For example...

import ucar.atd.dorade.*;
import ucar.ma2.*;
import ucar.nc2.dataset.conv.*;
[ October 09, 2006: Message edited by: marc weber ]
 
J. Bisa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply Marc,

as always: small mistake - big impact!

JB
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Importing using wildcards is considered by quite a lot of people, including me, to be a Bad Thing. It can lead to name clashes. Also, explicitly importing each class makes the dependencies clear.

If you don't use wildcard import at all, you can't get confused by what it does!
reply
    Bookmark Topic Watch Topic
  • New Topic