aspose file tools*
The moose likes Beginning Java and the fly likes Package Compilation Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package Compilation Problem" Watch "Package Compilation Problem" New topic
Author

Package Compilation Problem

sonu arora
Ranch Hand

Joined: Jul 25, 2002
Posts: 30
First File - abc.java
--
package test;
import test.sell.*;
public class def
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
--
second file - def.java
--
package test.sell;
import test.*;
public class abc
{

}
--
how to compile them , error- package import test.sell does not exist.


try & try u ll surely win.
sonu arora
Ranch Hand

Joined: Jul 25, 2002
Posts: 30
oops,
first file is def.java and second is abc.java.
Sadanand Murthy
Ranch Hand

Joined: Nov 26, 2003
Posts: 382
Originally posted by sonu arora:
First File - def.java
--
package test;
import test.sell.*;
public class def
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
--
second file - abc.java
--
package test.sell;
import test.*;
public class abc
{

}
--
how to compile them , error- package import test.sell does not exist.

Package hierarchy generally reflects directory hierarchy.
Why are you importing test.* in abc? You will end up with circular reference if you have classes in test referencing classes in test.sell package & classes in test.sell referencing classes in test package.
The way you have it, in order to be able to compile def.java, abc.java must be compiled first so that the package test.sell will be available. However in order to compile abc.java successfully, def.java must be 1st compiled so that package test will be available.
For the simplistic hello world, you don't need abc.java. Or are you trying to accomplish more than what you have shown in the code?


Ever Existing, Ever Conscious, Ever-new Bliss
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package Compilation Problem
 
Similar Threads
Unable to compile class for JSP
Package
Reflection
Packages
Importing Classes in default package