Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

java package problem

  • 02-04-2002 11:06pm
    #1
    Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭


    Lately I've been noticing that nothing works like it says on the tin. I paste code directly from tutorials/books and it never bloody works.



    I think my problem might be I'm thinking in terms of C++ classes instead of Java classes. Here's the class definition :
    <<wingaway.java>>
    package wingaway;


    public class wingaway
    {
    String local[][];
    int number;
    public void wingaway()
    {
    number = 0;
    local = new String[20][2];
    }
    ....................


    and the declaration :
    <<shortlist.java>>
    import wingaway.*;

    wingaway mywingaway = new wingaway():

    which gives the error :
    error: File .\wingaway.class does not contain type wingaway as expected, but type wingaway.wingaway. Please remove the file, or make sure it appears in the correct subdirectory of the class path.

    shortlist.java:22: Class wingaway not found.
    wingaway sessionVals = new wingaway();
    ^
    shortlist.java:22: Class wingaway not found.
    wingaway sessionVals = new wingaway();
    ^
    3 errors


Comments

  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    Is shortlist.java in a different directory from wingaway.java?? If so, are you adding the directory of your package to the classpath??


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    Ok if I'm ever importing 3rd party code (meaning anything other than Sun APIs), I copy the java source files to my current project working directory. I then remove any package information from the source file

    // ie.
    package mypackage;

    // the rest of your code goes here

    that way all the classes can reference eachother without you having to worry about physical class locations, dictated by packaging.

    On the otherhand if there is a **** load of classes, I would just reference the root directory of the package in my classpath. ;)

    ;-phobos-)


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    That seems to be working now - Thanks Phobos & thanks for the advice lynchie.

    I'll probably be buggered by this again in the future tho :) - and now my Cookie statements (also copied directly from Sun tutorials) are wonky. :)


Advertisement