aspose file tools*
The moose likes Beginning Java and the fly likes Acess Modifier Error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Acess Modifier Error?" Watch "Acess Modifier Error?" New topic
Author

Acess Modifier Error?

Lewis Mayer
Greenhorn

Joined: May 08, 2005
Posts: 9
I have two classes
TryStar.java &
Star.java in the package
package com.myself.SWING.TryStar;

TryStar.java has ------->


and Star.java has -------->

when I complie TryStar.java I get the error:

TryStar.java:13: cannot resolve symbol
symbol : class Star
location: class com.myself.SWING.TryStar.TryStar
Star application = new Star(points);

I SEE NO REASON WHY I CANT ACCESS STAR CLASS FROM HERE. ITs a PUBLIC class and in the same package!! Anybdy any ideas??
[ May 08, 2005: Message edited by: Manonthemoon sam ]
Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
This error is caused because the path to your package may not be specified in the classpath. To specify your package in the classpath do one of the following:

For setting temporary classpath:
javac -classpath com.myself.SWING.TryStar TryStar.java

Note: While setting this classpath make sure that your current directory is one level higher than the com folder.

For setting the classpath permanently(in Windows XP):

Right-click My Computer>>Properties>>Advanced>>EnvironmentVariables.

Then in System Variables search for the variable with name "CLASSPATH".
  • If its there then Edit it to include your classpath. Don't erase the other values. Separate your value from the others by a semi-colon. Click on OK thrice.


  • If its not there then click on New and set the name as "CLASSPATH" and the value as the path to your package. (Give the absoulte path)


  • Hope this helps.


    With Best Regards,
    Shyam Prasad Murarka
    Shyam Prasad Murarka
    Ranch Hand

    Joined: May 02, 2005
    Posts: 209
    The above post might not be the answer. I guess you just forgot to import the package.
    Shyam Prasad Murarka
    Ranch Hand

    Joined: May 02, 2005
    Posts: 209
    The above post might not be the answer. I guess you just forgot to import the package.
    Lewis Mayer
    Greenhorn

    Joined: May 08, 2005
    Posts: 9
    import the package for wht?
    The 2 classes are in the same package and it is mentioned as the first line of each class. So is there any need to import??
    Shyam Prasad Murarka
    Ranch Hand

    Joined: May 02, 2005
    Posts: 209
    As far as I can remember I think you have to import com.myself.SWING.TryStar.* Why don't you give it a try? And please let me know whether it works or not.
    Lewis Mayer
    Greenhorn

    Joined: May 08, 2005
    Posts: 9
    its the same error. importing too doesnt wrk.
    Henry Wong
    author
    Sheriff

    Joined: Sep 28, 2004
    Posts: 18896
        
      40

    There is no need to import if they are both in the same package.

    Take a peek to see if the compiler actually compiled all the sources.

    Henry


    Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
    Lewis Mayer
    Greenhorn

    Joined: May 08, 2005
    Posts: 9
    Exactly. Thts wht i was saying. And I did compile all sources. Jst beats me hw it's giving an error!
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    What is the exact command you use to compile the sources? From which folder do you compile? What does your classpath look like?


    The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
    Neeraj Dheer
    Ranch Hand

    Joined: Mar 30, 2005
    Posts: 225
    hey Java Man!!

    apart from answering your query...you will most probably be asked to change your name according to the naming policy...

    <first name><space><last name> and let them be believable first and last names...
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Acess Modifier Error?