PDA

View Full Version : Please, help with packages


Louis_mine
02-12-2006, 12:40 AM
Hi, I am working on a schoool project and I was told to create a Package, I did it, but when the porgram is supposed to be executed it says it won't find the class, I have looked for answers on the tutorials I have, but there are not, please help.

I wrote my class which is supposed to be as a part of the package, the first line is:

package proyecto1.src.banco;

then my code...

in another file, my main class which is supposed to call that one, the first line is:
import proyecto1.src.banco.*

my first file is inside the directory C:\proyecto1\src\banco
the second one is inside c:\proyecto1\src

I compile form c:\...\src my file with the main using
javac -d ../classes FileName.java

it compiles correctly and saves my class in c:\proyecto1\classes
then I move to the directory classes and run it from there, but it says the class FileName.class cannot be found, I am really upset and tired of trying, any help is really apreciated
thx

_Dan
02-12-2006, 09:23 PM
I don't really have any idea, but perhaps you could try with all files in the same directory.

Ender
02-13-2006, 01:27 AM
I'm not sure I get your question. You need compiled .class files for every source file you are using. So if you have a .class file for class Main in source file Main.java, but not one for your class Whatever in Whatever.java, then it's not going to work. Main.java will compile fine if there is no Whatever.class, but it will throw an error if there is no Whatever.class at runtime.

The class files should be located at the directory of the import statement.

If that's not your question, please restate it.