|
-
Apr 17th, 2002, 11:34 PM
#1
Thread Starter
Addicted Member
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
-
Apr 18th, 2002, 09:47 AM
#2
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.
.
-
Apr 18th, 2002, 10:00 AM
#3
Thread Starter
Addicted Member
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
-
Apr 19th, 2002, 04:16 AM
#4
Well ...
Originally posted by honeybee
Also try adding "." which stands for the current directory, to the classpath.
.
.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|