Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

compilation problem

SweetPSweetP Posts: 35Member
the jsp board seems kinda deserted, so i'm gonna post this here.....

i am currently studying exceptions within jsp and having a problem compiling a class.... i have hit the errata discussion boards but nothing was posted about this, so hopefully i can get the answer here....

the following is my code straight out of my book, but it doesn't compile... the goal is to utilize a custom Exception class called UserException that i defined:

#################################

package com.wrox.errors;

public class ImprovedUser extends Object implements java.io.Serializable{

public ImprovedUser() {};
private String username;
private String password;

public void setUsername(String name){
username = name;
}

public String getUsername(){
return username;
}

public void setPassword(String pass){
password = pass;
}

public void validateUser() throws Exception, NullPointerException{
if(username==null){
throw new UserException("Must supply a username!",null);}
if(password==null){
throw new UserException("Must supply a password!",username);}
if(!(username.equals("Casey") && password.equals("Kochmer"))){
throw new UserException("Couldn't validate password!",username);}
}
}

#################################

here are the errors i am getting; 3 of the same kind:

#################################

C:jakarta-tomcat-5.0.28webappsegjsp-ch09WEB-INFclassescomwroxerrors>javac ImprovedUser.java
ImprovedUser.java:23: cannot resolve symbol
symbol : class UserException
location: class com.wrox.errors.ImprovedUser
throw new UserException("Must supply a username!",null);}
^
ImprovedUser.java:25: cannot resolve symbol
symbol : class UserException
location: class com.wrox.errors.ImprovedUser
throw new UserException("Must supply a password!",username);}
^
ImprovedUser.java:27: cannot resolve symbol
symbol : class UserException
location: class com.wrox.errors.ImprovedUser
throw new UserException("Couldn't validate password!",username);}
^
3 errors

#################################

please note that UserException.class is in the same directory as ImprovedUser.java and that is in the errors directory mentioned in the package reference at the top of the ImprovedUser.java file above............

any help will be appreciated....

Thanks!

Pete

Comments

  • moomoo Posts: 147Member
    ...

    :C:jakarta-tomcat-5.0.28webappsegjsp-ch09WEB-INFclassescomwroxerrors>javac ImprovedUser.java
    : ImprovedUser.java:23: cannot resolve symbol
    : symbol : class UserException
    : location: class com.wrox.errors.ImprovedUser
    : throw new UserException("Must supply a username!",null);}
    :
    :

    ...
    ^
    : #################################
    :
    : please note that UserException.class is in the same directory as ImprovedUser.java and that is in the errors directory mentioned in the package reference at the top of the ImprovedUser.java file above............

    ...


    Hi, i think the problem is that you are in the wrong directory calling javac. Try this:
    [code]
    C:> cd C:jakarta-tomcat-5.0.28webappsegjsp-ch09WEB-INFclasses

    C:jakarta-tomcat-5.0.28webappsegjsp-ch09WEB-INFclasses>javac comwroxerrorsImprovedUser.java
    [/code]

    This might work
    greetings mo
Sign In or Register to comment.