This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help!!!!! calling an instance of a class

 
nash avin
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I hope this is the right forum to post this topic.I am doing so cause I am dealing with servlets.In the init() method of a servlet.I want to call an instance of another class UserPresent.java .I will post the code below


The compiler keeps complaining saying that .......
[bold]
AuthenticateServlet21.java:12: cannot resolve symbol
symbol : class UserPresent
location: class package1.structure.AuthenticateServlet21
UserPresent userpresent = new UserPresent();
[/bold]
I have included the package package1.structure in both the servlet code and the UserPresent code.
Kindly let me know what could be the problem.
Help would be appreciated
Thanks
AS
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nash,
Are these two .java files in the same folder on your machine? Also, are you trying to compile them together or separately? Try doing a:
javac *.java
 
nash avin
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,
I did compile as you directed.
javac *.java but....I am getting the same errors.
Let me know what could be the problem.
Thanks
AS
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would first make sure UserPresent.java is in the same directory/folder structure as AuthenticateServlet21.java.

I would suggest, first compiling UserPresent.java and then your servlet.
This will verify that there are no problems with UserPresent.java (i.e. package name, class name etc).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic