Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

cannot resolve symbol

This the error description:

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07\WEB-I
NF\classes\com\wrox\library>javac ChildrenBook.java
ChildrenBook.java:3: cannot resolve symbol
symbol  : class BookNew
location: class com.wrox.library.ChildrenBook
public class ChildrenBook extends BookNew {
                                  ^
1 error
==========
These are the classes:

package com.wrox.library;

public class ChildrenBook extends BookNew {

      private int minmumAge;
      
      public int getMinmumAge() {
            return minmumAge;
      }
      
      public void setMinmumAge(int a) {
            minmumAge = a;
      }
      
      public ChildrenBook() {
            super();
      }
      
      public ChildrenBook(String title) {
            super(title);
      }      
}

===============
package com.wrox.library;

public class BookNew {

      private String title;
      
      public String getTitle() {
            return title;
      }
      
      public void setTitle(String title) {
            this.title = title;
      }
      
      public BookNew() {
      }
      
      public BookNew(String title) {
            this.title= title;
      }      
}

Question: What is wrong? How can I correct the problem I am having?

When I combine public class ChildrenBook and class Book in the same file it works okay. Basicallt it comes down to how I need to change the first line in my CheldrenBook class so it can find Book class. Do I need to revise PATH string somewhere?

package com.wrox.library;


I will try this in for now until someone could figue out what is happening here. Also I am reading about tag libraries and tag handlers in case the problem may is related.

Thank you.
Avatar of rrz
rrz
Flag of United States of America image

First;
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07\WEB-INF\classes\com\wrox\library>javac  BookNew.java  
That will put the BookNew.class file into the current directory.  
Second;
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07\WEB-INF\classes\com\wrox\library>javac  -cp "C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07\WEB-INF\classes"  ChildrenBook.java
That will place the ChildrenBook.class file along side of BookNew.class .
The -cp is an option. Type  
>javac -help
to see options.

Alternatively you can use;  
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07\WEB-INF\classes\com\wrox\library>javac  *.java  
That will compile both with one command.  

Most people use a tool. Ant, Maven, or a IDE(NetBeans, Eclipse).
Ant is really handy. I can show you the basics.  

>Also I am reading about tag libraries and tag handlers in case the problem may is related.  
Good, but not related to this.
Avatar of Mike Eghtebas

ASKER

rrz@871311,

Thank you for your post.

re:> I can show you the basics.
I use netbeans at home. I will do whatever at work they do (using c-prompt).

There are a number of issues I can start with, but I will write about one of them at this point. I think, if I can handle this one, all others will be resolved also.

1. I have Book.java at C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07x\WEB-INF\classes\com\wrox\library

and it compiles fine (note x at the end of begjsp-ch07x to test my work here).

2. I have the following jsp to use it:

<html>
      <head>
            <title>A Simple Class</title>
      </head>
      <body>
            <jsp:useBean id="myBook" class="com.wrox.library.Book" />
            <jsp:setProperty name="myBook" property="title" value="Begining JSP Web Development" />
            Book Title: <jsp:getProperty name="myBook" property="title" />
            
      </body>
</html>

But it doesn't work. I get the attached error.txt file. I use this url to run it: http://localhost/begjsp-ch07x/bookPage.jsp
(FYI http://localhost/begjsp-ch07x/bookPage1.jsp works okay its content is:

<html>
      <head>
            <title>A Simple Class</title>
      </head>
      
      <body>

            <% com.wrox.library.BookNew myBook = new com.wrox.library.BookNew("Begining JSP Web Development"); %>

            Book Title:
            <% out.println(myBook.getTitle()); %>
             
      </body>
</html>

Why bookPage1.jsp works but bookPage.jsp doesn't?)

Also, the computer is setting is usiing 80 (default) not 8080 hence is not included.

Do you see why it works in the case of one but not the other?

Mike
error.txt
So Book and BookNew are two different types ?
Is the the Book.class file at
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07x\WEB-INF\classes\com\wrox\library\Book.class  
?
My bad, I changed

<jsp:useBean id="myBook" class="com.wrox.library.Book" />
to
<jsp:useBean id="myBook" class="com.wrox.library.BookNew" />

which means my Book class has some errors,

brb
The are identical:
package com.wrox.library;
public class Book {
      private String title;
      public String getTitle() {
            return title;
      }
      public void setTitle(String title) {
            this.title = title;
      }
      public Book() {
      }
      public Book(String title) {
            this.title= title;
      }      
}

========
package com.wrox.library;
public class BookNew {
      private String title;
      public String getTitle() {
            return title;
      }
      public void setTitle(String title) {
            this.title = title;
      }
      public BookNew() {
      }
      public BookNew(String title) {
            this.title= title;
      }      
}

I don't know why the reeor then?
Is the the Book.class file at
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07x\WEB-INF\classes\com\wrox\library\Book.class  
?
Yes, both classes are in the same directory: C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch07x\WEB-INF\classes\com\wrox\library\
ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It decided to work now. Someone things this sometimes happens because of network issues etc.

brb
i will test your code noe...
This was smart way of checking Book class.

Thanks,

Mike
I meant to accept:

<html>
      <head>
            <title>A Simple Class</title>
      </head>
     
      <body>

            <% com.wrox.library.Book myBook = new com.wrox.library.Book("Begining JSP Web Development"); %>

            Book Title:
            <% out.println(myBook.getTitle()); %>
             
      </body>
</html>
                                           

solution.