?
Solved

Stuck with Packages!

Posted on 2003-02-20
8
Medium Priority
?
242 Views
Last Modified: 2010-03-31
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

0
Comment
Question by:KarcOrigin
7 Comments
 
LVL 3

Expert Comment

by:allahabad
ID: 7991476
Please do this;
C:\glueI>javac c:\glueI\corejavalib\DBAdapter.java

0
 
LVL 1

Expert Comment

by:membersh
ID: 7991502
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...
0
 
LVL 5

Author Comment

by:KarcOrigin
ID: 7991757
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:msterjev
ID: 7991903
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";
    }
}
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 7992880
You don't need a classpath so:

C:\gluel>SET CLASSPATH=

then

C:\gluel>javac corejavalib\DBCommond.java

then

C:\gluel>javac corejavalib\DBAdapter.java

0
 

Expert Comment

by:CleanupPing
ID: 9059180
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.
0
 
LVL 7

Expert Comment

by:tomboshell
ID: 9582087
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question