Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    22

    Question Unanswered: Cannot compile a class with a package

    Hello,

    I am trying to implement the package example from the SUN Tutorial. It can be found on the page: http://java.sun.com/docs/books/tutor...questions.html

    I think I am doing like described but it doesn´t work. The files are stored like following on my machine:

    C:\mygame\Shared\Utilities.java (this file can be compiled)
    C:\mygame\Server\Server.java (can´t be compiled)
    C:\mygame\Client\Client.java (can´t be compiled)

    I have no CLASSPATH set (but I tried), Java is installed in C:\Java\j2sdk

    If I try to compile the file Client.java with javac the following error message occurs:


    C:\mygame\Client>javac Client.java
    Client.java:7: cannot resolve symbol
    symbol : class Utilities
    location: package shared
    import mygame.shared.Utilities;
    ^
    Client.java:23: cannot resolve symbol
    symbol : variable Utilities
    location: class mygame.client.Client
    Utilities.printMsg("creating output stream");
    ^
    Client.java:32: cannot resolve symbol
    symbol : variable Utilities
    location: class mygame.client.Client
    Utilities.printMsg("writing current date");
    ^
    3 errors



    Are there any further prerequisites?
    Thank you

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Cannot compile a class with a package

    Originally posted by Rasti

    C:\mygame\Shared\Utilities.java (this file can be compiled)
    ...

    C:\mygame\Client>javac Client.java
    Client.java:7: cannot resolve symbol
    symbol : class Utilities
    location: package shared
    import mygame.shared.Utilities;
    ^
    Package names are case-sensitive. Besides, the way you do it you'll have to have your Utilities class in c:\mygame\Client\mygame\utilities directory or set your CLASSPATH to point to all three class files.

    You may want to read this:
    http://java.sun.com/docs/books/jls/s...doc.html#37546

    and this:
    http://java.sun.com/docs/books/tutor...gingfiles.html
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •