wood burning stoves*
The moose likes Beginning Java and the fly likes Strange prob with Library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Strange prob with Library" Watch "Strange prob with Library" New topic
Author

Strange prob with Library

J. Bisa
Greenhorn

Joined: Oct 09, 2006
Posts: 2
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

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
J. Bisa
Greenhorn

Joined: Oct 09, 2006
Posts: 2
Thanks for the quick reply Marc,

as always: small mistake - big impact!

JB
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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!


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange prob with Library
 
Similar Threads
Classpath, lib directory, and lots of libraries!
Eclipse not seeing updated JAR in tomcat\lib library at runtime
Serializing/ Importing Packages/Classpath issues
EJB Deployment with JARS
Running Thread in Servlet container