PDA

Click to See Complete Forum and Search --> : Class Location Probelm - Can't Resolve Symbol


cantene
Apr 18th, 2002, 12:34 AM
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

honeybee
Apr 18th, 2002, 10:47 AM
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.

.

cantene
Apr 18th, 2002, 11:00 AM
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

honeybee
Apr 19th, 2002, 05:16 AM
Originally posted by honeybee
Also try adding "." which stands for the current directory, to the classpath.

.

.