wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes package works only with importing individual class?? 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 "package works only with importing individual class??" Watch "package works only with importing individual class??" New topic
Author

package works only with importing individual class??

Gong Li
Greenhorn

Joined: May 24, 2002
Posts: 1
i have two java test program in different package: one in default package and one in user defined package..when I tried to use the class in the user define package by importing the whole package, compile error occured: can't resolve symbols,for whatever constructor or methods in the imported package. but when i import individual class, everything works perfect. any one knows why??
here is the test program
ReadNumber.java
package user.test;
public class ReadNumber{
public ReadNumber(){
System.out.println("this is a line from ReadNumber2 constructor");
}
public void test(){
System.out.println("this is a line from test() in readNumber");
}
public static void main(String arg[]){
ReadNumber rn=new ReadNumber();
System.out.println("this is a line from main");
}
}
TestReadNumber.java
import user.test.ReadNumber; //compiles fine
//import user.test.*; //this won't compile
public class TestReadNumber{
public static void main (String arg[]){
ReadNumber rn = new ReadNumber();
rn.test();
}
}
anyone have any idea why it happened this way..thanks
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Gong
This is only a guess but is your user defined package in a JAR? The * functionality might only work for JARed classes.
Someone else can probably shed more light on it.


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package works only with importing individual class??
 
Similar Threads
assignment operator
Question ID :962546675280 jqplus
Constructor
Is There No Such Thing as a Root Package?
an unbelievable question about import!!!