aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to use class in same package" Watch "How to use class in same package" New topic
Author

How to use class in same package

Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126
Hello

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.

Regards
Gaurav
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

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: http://aspose.com/file-tools
 
subject: How to use class in same package