• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Importing classes problem

 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the java code please.
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In dto folder:


In dao folder:
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic