Link to home
Start Free TrialLog in
Avatar of KarcOrigin
KarcOrigin

asked on

Stuck with Packages!

Dear BrainBags,

This is a very simple problem which has taken my good amount of time. I am using 2 java files which are in my corejavalib directory. My directory structure is something like this -

C:\glueI\corejavalib

and my 2 java files are in corejavalib directory since these files are the part of corejavalib package. Here is a simple code of my 2 java files.

/* DBAdapter.java file */
package corejavalib;

public class DBAdapter
{
     DBCommond myC = new DBCommond();

     public String getAdaptorName()
     {
          return "ORACLE";
     }
     
     public String getCommondTypeMode()
     {
          return myC.getCommondType();
     }
}



/* DBCommond.java file */
package corejavalib;

public class DBCommond
{
     public String getCommondType()
     {
          return "INSERT";
     }
}


Now the problem is that when I compile DBAdapter.java file it gives me the error that it cannot able to compile DBCommond class. Can anybody help me? If I have to change something in my classpath or path please tell me excatly according to the above directory sturture.

* Just for your information I have already set my CLASSPATH to .;C:\glueI; and my PATH variable is set to the directory where my javac file exsits.

Thanks.
Karc Origin

Avatar of allahabad
allahabad

Please do this;
C:\glueI>javac c:\glueI\corejavalib\DBAdapter.java

You have 2 options
1. javac -d . DBCommond.java & then javac -d . DBAdapter.java

2. In command prompt, goto corejavalib directory, add '.' to CLASSPATH, then javac DB*.java

2nd option is suggested if all files in ur package starts with DB...
Avatar of KarcOrigin

ASKER

Dear allahabad and membersh I have tried your options but none of them works.

Anyways thank you very much. Keep the good work going on.

Karc Origin
Try this:

package corejavalib;

public class DBAdapter
{
    DBCommond myC;

    public DBAdapter()
    {
       myC=new DBCommond();
    }


    public String getAdaptorName()
    {
         return "ORACLE";
    }
   
    public String getCommondTypeMode()
    {
         return myC.getCommondType();
    }
}




package corejavalib;

public class DBCommond
{
    public DBCommond(){}

    public String getCommondType()
    {
         return "INSERT";
    }
}
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
KarcOrigin:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept CEHJ's comment as answer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thomas Boshell
EE Cleanup Volunteer