File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange prob with Library

 
J. Bisa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply Marc,

as always: small mistake - big impact!

JB
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic