Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me to figure out problem in calling class in simple servlet

Status
Not open for further replies.

nidhi231

Programmer
Feb 1, 2008
2
US
Hello all

Kindly help me to figure what is the mistake i am making while calling the simple class file in a servlet.

i have written a simple servlet and name it as LoginServer.java i am trying to call a class which i have in other notepad and saved it as Hello.java . i have complied Hello.java and after complilation i see class file of it.
In Servlet LoginServer i have used below command to call the class.

Hello h=new Hello();
but it gives me error cannot resolve symbol.Below is the error


C:\bea\punky\user_projects\punky\applications\DefaultWebApp\WEB-INF\classes>java
c LoginServer.java
LoginServer.java:19: cannot resolve symbol
symbol : class Hello
location: class LoginServer
Hello h= new Hello();
^
LoginServer.java:19: cannot resolve symbol
symbol : class Hello
location: class LoginServer
Hello h= new Hello();
^
2 errors

i have stored both servlet(LoginServer.java) and Hello.java in the same folder (same path)and i am trying to compile it in weblogic.
path is
C:\bea\punky\user_projects\punky\applications\DefaultWebApp\WEB-INF\classes
can anyone suggest what is the mistake that i might be making to get above error.
below is the code
===================
saved simple class as Hello.java
============
class Hello {
int length;
}

=================================
saved simple servelet as LoginServer.java
==================
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServer extends HttpServlet
{


public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{


try
{ PrintWriter out= res.getWriter();
res.setContentType("text/html");

Hello h= new Hello();
out.println("This is a sample servlet");
out.close();
}
catch(Exception e){}
}
}

============================================
thanks in advance for your time .
nidhi
 
You have to pass both Java files to the javac command.
 
thankyou everyone for taking your timeout .

My problem is solved now . i made few changes in my CLASSPATH i gave i whole path where i kept i jave files from
C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jre1.6.0_01\lib.;

to

C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jre1.6.0_01\lib.;C:\bea\nidhi\user_projects\nidhidomain\applications\DefaultWebApp\WEB-INF\classes

and it solved my problem and yes dont forget to open
new cmd .hope it helps someone facing the same problem .i never use to make any changes in classpath for weblogic but it seems sometimes we have to give whole path.
 
my classpath start with
.;c:\jdk142xxxxxxxxxxxx;
Please focus on the full dot at the beginning. It means the classpath include the current directory where you type javac

When you are working with Java, the company may need back compatible, so I use JDK1.4 ^^
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top