p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   J2EE (http://p2p.wrox.com/forumdisplay.php?f=94)
-   -   problem in calling classes in simple Servlet (http://p2p.wrox.com/showthread.php?t=65662)

sanna231 February 2nd, 2008 12:27 AM

problem in calling classes in simple Servlet
 
Hello all

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

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

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


C:\bea\nidhi\user_projects\nidhidomain\application s\DefaultWebApp\WEB-INF\classe
s>javac Eemlogin.java
Eemlogin.java:62: cannot resolve symbol
symbol : class LoginEemCompare
location: class Eemlogin
LoginEemCompare lc=new LoginEemCompare();
^
Eemlogin.java:62: cannot resolve symbol
symbol : class LoginEemCompare
location: class Eemlogin
LoginEemCompare lc=new LoginEemCompare();
                       ^
2 errors

i have stored both servlet(Eemlogin.java) and LoginEemCompare.java in the same folder and i am trying to run it in weblogic.
can anyone suggest what is the mistake that i might be making to get above error.if you want i can also send the code.

thanks in advance for your time .
nidhi


jomet February 2nd, 2008 02:37 AM

Hi,

use
javac -cp . *.java
(this is another way to tell the files are in current dir)

Cheers,

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.

sanna231 February 6th, 2008 02:01 AM

hello jomet

thankyou for your suggestion . i tried the command given by you but it is still giving me the same error . even tried to make some changes in my classpath from
C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jre1.6.0_01\lib.;

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

but nothing is working for me . Can you suggest me something else.

thankyou in advance for your time

nidhi


sanna231 February 6th, 2008 05:16 PM

hello all

My problem is solved now . i changed claspath 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_proj ects\nidhidomain\applications\DefaultWebApp\WEB-INF\classes;

and it works now for me . yesterday accidently i had not opened new cmd so it did not work and today i tried it again and now it works.
hope this helps someone else if they face same problem . i never used to make changes in Classpath for weblogic but seems sometimes we need to give full path where we keep the java files .

thanks
nidhi


jomet February 7th, 2008 11:27 PM

Hi,

Glad to know u solved it.
path changes will take effect when we open the cmd window.

Cheers,

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.

santbir July 11th, 2012 11:44 AM

problem in calling classes in simple Servlet
 
Hello Jomet,

I am facing the same problem. And also tried both ways but i am not successfull. I don't know why??

I have one servlet (Register.java)
and a java class(Function.java)

First I compiled Function.java successfully but
When i compiling Register.java its giving me error Function class not found

In both way :-

1. javac -cp . *.java or javac -classpath . *.java

2. copying the class path where my from my tomcat path like:-

C:\Program Files (x86)\Apache Software Foundation\Apache Tomcat 7.0.22\webapps\loginnapp\WEB-INF\classes

but in both cases i am getting a common error:-

import javax.servlet.*;
^
Register.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Register.java:5: package javax.servlet does not exist
import javax.servlet.*;
^
Register.java:8: cannot find symbol
symbol: class HttpServlet
public class Register extends HttpServlet
^
Register.java:10: cannot find symbol
symbol : class HttpServletRequest
location: class Register
public void doGet(HttpServletRequest req, HttpServletResponse res) throw
s IOException, ServletException
^
Register.java:10: cannot find symbol
symbol : class HttpServletResponse
location: class Register
public void doGet(HttpServletRequest req, HttpServletResponse res) throw
s IOException, ServletException
^
Register.java:10: cannot find symbol
symbol : class ServletException
location: class Register
public void doGet(HttpServletRequest req, HttpServletResponse res) throw
s IOException, ServletException

^
Register.java:28: cannot access Functions
bad class file: .\Functions.class
class file contains wrong class: classes.Functions
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
Functions fe=new Functions();
^
8 errors


please help me friends i m stuck

anoopnyati December 23rd, 2012 01:06 AM

Yes its working!
 
Hi Nidhi,
Thanks a lot for your suggestion. I did the same changes in my classpath and it worked for me too!
Thanks for it!

Quote:

Originally Posted by sanna231 (Post 217129)
hello all

My problem is solved now . i changed claspath 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_proj ects\nidhidomain\applications\DefaultWebApp\WEB-INF\classes;

and it works now for me . yesterday accidently i had not opened new cmd so it did not work and today i tried it again and now it works.
hope this helps someone else if they face same problem . i never used to make changes in Classpath for weblogic but seems sometimes we need to give full path where we keep the java files .

thanks
nidhi



All times are GMT -4. The time now is 06:19 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.