Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package works only with importing individual class??

 
Gong Li
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic