• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Problem with packages!!!

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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]
GUI.java
ResultPane.java

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]
QueryGD.java
FilterSearch.java
Scheduler.java
AttributeStore.java
CustomParser.java

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]
DBConnect.java
ResultStore.java

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
th.
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!!!
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Off to "Java in General (Beginner)."
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic