| Author |
Importing classes problem
|
shaf maff
Ranch Hand
Joined: Sep 07, 2008
Posts: 180
|
|
Hi Guys
I have two folders in my classes folder, one called "dao" and another called "dto", both contain various classes . The problem I am having is I am trying to include a class from the dto package in one of my dao classes but I keep getting errors that it cannot be found. I am using the following import statement:
import dto.MyClass;
Does anyone know why its not working ?
|
 |
Sam Codean
Ranch Hand
Joined: Feb 26, 2006
Posts: 194
|
|
|
Can you post the java code please.
|
-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
|
 |
shaf maff
Ranch Hand
Joined: Sep 07, 2008
Posts: 180
|
|
In dto folder:
In dao folder:
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24056
|
|
When you compile or run your program, you need to include the "classes" directory on your classpath, and compile (or run) using the full paths/classnames. So, for example
C:\CLASSES> javac -cp . dto\*.java dao\*.java
C:\CLASSES> java cp . app.Main
That's javac dash cp space dot space dto slash star dot java space dao slash star dot java .
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: Importing classes problem
|
|
|