Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
  • 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!
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic