wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "packages" Watch "packages" New topic


Daniela Ch
Ranch Hand

Joined: Dec 13, 2002
Posts: 96
I have an application that have 3 packages. I am supposed to be able to compile each package alone?
I deleted all the classes and recompiled them.
I am got errors that said it need specific classes from the two other packages...
Does this mean that I should put all the files that needs each other in the same one?
thank you
Junilu Lacar

Joined: Feb 26, 2001
Posts: 4444

You compile programs (.java), not packages. Anyway, you need probably need to import classes that are in other packages:
import package1.*;
import package2.*;
Moving this to Java in General (Beginner)

Junilu - [How to Ask Questions] [How to Answer Questions]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Also, the compiler will need to be able to locate the other packages through the CLASSPATH setting when compiling.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Daniela Ch
Ranch Hand

Joined: Dec 13, 2002
Posts: 96
I allready have all the imports I need to compile, and I have allready set the classpath.
I dont get compilation errors when I dont erase the .classes
When I remove all the .class and want to recompile everything, I have to follow an order :
Compile class B.java in packageB to be able to compile class A.java in packageA wich also need class C.java in packageC etc...
I can not compile one package at the time...
Is this bad?
Arvind Varma
Ranch Hand

Joined: Dec 24, 2002
Posts: 48
That is not bad...because when you compiled package A(depends on Package B)the compiler looks for the required .class files in package B and since u removed all of them it throws errors....so its basically u r not instructing it correctly. you can solve this in two ways :
Compile the packages in the order of dependencies or compile all the files
together in a single command *.java
Daniela Ch
Ranch Hand

Joined: Dec 13, 2002
Posts: 96
ah ok, thank you Arvind...
do you know the javac arguments to compile all java file in subdirectories?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: packages
Similar Threads
How to complile java classes which exist in different Packages
compiling interdependent classes and packages
tool to find missing documentation in Java Project
compiling interdependent classes and pachages