Results 1 to 4 of 4

Thread: Class Location Probelm - Can't Resolve Symbol

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    hongkong
    Posts
    251

    Class Location Probelm - Can't Resolve Symbol

    Dear friends,

    I wish to ask a question.

    I wish to write a class Database (function as a wrap-up of JDBC-ODBC database connection) which is public for all other classes to use.

    Database.java
    public class Database {

    }

    I write a serlvet class called GetUserInfo which uses an object of type Database as follows:

    GetUserInfo.java
    public class GetUserInfo extends HttpSerlvet {
    private Database db;

    init() {
    db = new Database(url, user, password);
    :
    }
    :
    }

    These 2 text files are placed in the same directory.
    I first compiled Database.java and created Database.class.
    But when I compile GetUserInfo.java, why it blames
    "Can't resolve symbol: Database"

    Then I go to Control Panel > System to change the CLASSPATH env var to include the full name of the Database.class:
    d:\www-root\webapps\Database.class

    while my jdk is installed on c: drive c:\jdk.

    But the same result!

    I saw some program uses package aName at top of all java sources. I think I just need to name them in the same package will be Okay, but the same result! So I wish to know how to use package?

    Would you mind helping on this problem? Thanks a lot

    Cantene

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Try writing it inside the servlet class. That will not make it public as you desire, but will at least get your work going.

    Creating a package is a good option too. Also try adding "." which stands for the current directory, to the classpath.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    hongkong
    Posts
    251

    But ...

    Thank you for honeybee.

    I have already used the way u mentioned to get the class compiled. But this is not what I want as it is impractical to put the Database code in every servlet program. The purpose of writing Database.java is to make a shared utility for all serlvets.

    Do u have the experience of making a

    public class A

    and declare an object of type A

    in public class B ?

    It should not be too diff. to achieve but I just get it stuck.

    If dear friends you know, may you grant me a reply.
    Thanks

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Originally posted by honeybee
    Also try adding "." which stands for the current directory, to the classpath.

    .
    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

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



Click Here to Expand Forum to Full Width