• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with packages!!!  RSS feed

Mehul Mistry
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can anyone help me problems i'm getting while bundling my project into packages.I've divided my classes itno three packages. The following is the distribution of classes...

package 1: eSearch [2 classes]

Both classes has " package eSearch; " as the first line. And to acceses the other packages below it, i've included " import GdInterface.*; " and " import GdInterface.DBdriver.*; " statements.

package 2: eSearch.GdInterface [5 classes]

Here also all classes have " package eSearch.GdInterface; " as the first line of the code. To acceses the lower classes it has " import DBdriver.*; " statement wherever required.

package 3: eSearch.GdInterface.DBdriver [2 classes]

Here also both classes have " package eSearch.GdInterface.DBdriver; " as the first statement.

The Folder structure for the entire hierarchy is "eSearch/GdInterface/DBdriver".Package eSearch is on topmost level,then in it there is GdInterface package which inturn has DBdriver package.I've also made all classes as public too.

Also i'm using third party jar files for my project.Where to put all the jar files to make them accesible during compiling and running the project.

NOw the problem comes while compiling. In the folder "esearch" (top most in the hierarchy) i compile GUI.java, which is the main class.But immediately it gives the following error......

GUI.java:60: cannot access GdInterface.DBdriver.DBConnect
bad class file: .\GdInterface\DBdriver\DBConnect.class
class file contains wrong class: eSearch.GdInterface.DBdriver.DBConnect
Please remove or make sure it appears in the correct subdirectory of the classpa
DBConnect dBase;
1 error

And similarly if i try to compile the classes first in it eSearch/GdInterface forder.Its not getting my classes in different folder.I'm using JDK1.5 on windows XP.

Can anyone help me out with this.I've got deadline to meet. I don't know where i'm going wrong!!!ALSO I WANT TO MAKE THISAS A JAR FILE AFTER COMPILING!!!
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For command line compiling your "current directory" needs to be the parent of the first node of the packages. So if your package starts with "eSearch" you might need to be in "src".

See if this tutorial helps.
Ernest Friedman-Hill
author and iconoclast
Posts: 24217
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off to "Java in General (Beginner)."
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!