Java Packages question

Hello,

Again simple things send me nuts.

Here is the scenario..

I have two classes in the same package.
1. I need to make thoese two classes available to the outside the package so any other java application can instantiate it

2. I MUST allow any of these two classes to create an instance of the other.

This is an example os I have.....

package a.b.c.d;

class X
{
}
=======================
package a.b.c.d;

import a.b.c.d.*;

class Y
{
  public static void main(String [] args)
 {
   X   xx = new X();   //I am getting an error saying that it cannot find the class.
  }
}

I have set the CLASSPATH to a.b.c.d.

Whats the solution.
prainAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StillUnAwareCommented:
The classpath should point to parent directory of a package a.b.c.d. In other words do this:

say Your parent dir is c: then
1) add to classpath c:
2) put Your source to c:\a\b\c\d
3) compile the source and make sure it stays in a directory c:\a\b\c\d
4) now run Your code in c: like that:  java a.b.c.d.Y

it should work
0
prainAuthor Commented:
Ok. I was wrong in writing that classpath line. Well I have set the classpath correctly - to the parent.

I  does not work.

Where are the experts here?
0
objectsCommented:
> import a.b.c.d.*;

thats not needed as class is in same package

> class X

declare the class public

public class X

same for class Y
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mayank SAssociate Director - Product EngineeringCommented:
Have a look at this for a brush up on classpath:

http://www.mindprod.com/jgloss/classpath.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.