File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How to use class in same package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to use class in same package" Watch "How to use class in same package" New topic

How to use class in same package

Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126

I have a page name RegisterForm and i compiled that and it is defined public. I have another page named RegisterAction and i want to make a object of RegisterForm in RegisterAction.

I have written in RegisterAction that -:

RegisterForm rf = (RegisterForm) form;

Then it is giving the error that
RegisterForm ---:: cannot resolve symbol
I have extended the registerAction class with some other class.
What should i do.
Both are in same package.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15083

If both classes are in the same package and you have the source files in the same directory, you should not be getting the "cannot resolve symbol" error.

Does RegisterForm compile without errors?
Do you have the same package statement in both source files?
Are the source files in the same directory?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Anirvan Majumdar
Ranch Hand

Joined: Feb 22, 2005
Posts: 261
If both the classes belong to the same package and you've got the import statements in place too, then the only reason why you could be facing the "Cannot resolve symbol" problem is that the compiler searches for the "imported" class file in the path specified in your "CLASSPATH". Try appending your CLASSPATH with ";.;" ,this would basically direct the compiler to search in the present working directory for the .class files too.
I agree. Here's the link:
subject: How to use class in same package
It's not a secret anymore!