File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes urgent: please help: importing variables interdependent classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

urgent: please help: importing variables interdependent classes

Abhi Chat
Ranch Hand

Joined: Oct 10, 2004
Posts: 57
Im tryin to use a variable of class x in class y, and vice versa. they are in the same package. Now the problem is i cacnot compile claas x as it says variable not found and niether class y as it gives the same error.

My problem is : i have 2 class x which is the GUI and classs Y which does the prser of the file and gives result. Class Y needs the name of the file which the user accepts through JFIleChooser, and does the work. Now class X calls the method of class y to get results. Now i cant compile class y as it needs the variable from class X and neither can class X as it needs the method from class Y.

Please advice

SCJP 1.4<br />Preparing for <br />SCJD and SCWCD
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sounds like this oughtta work. (Whether it's a good design or not is for another day.) There are all kinds of "circular references" in common code. Can you include some code and some error messages? Code fragments --- just where things are declared and referenced --- are probably enough. Are you using an IDE or compiling from the command line?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
This thread was also posted in "Java in General (advanced)". Please don't cross-post.

You got more answers over there. Maybe because you didn't put "urgent" in the subject. Please don't.
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

Please don't post the same thread in multiple forums. It makes a conversation difficult to follow, and wastes peoples time when they answer a question that's already been answered elsewhere.

Please continue teh conversation here.
I agree. Here's the link:
subject: urgent: please help: importing variables interdependent classes
It's not a secret anymore!