Solved

cannot resolve symbol

Posted on 2012-04-02
12
557 Views
Last Modified: 2012-04-03
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.
0
Comment
Question by:Mike Eghtebas
  • 8
  • 4
12 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 37799075
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.
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37801807
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
0
 
LVL 27

Expert Comment

by:rrz
ID: 37802075
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  
?
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37802130
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
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37802160
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?
0
 
LVL 27

Expert Comment

by:rrz
ID: 37802201
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  
?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37802213
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\
0
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 37802269
What happens if you change your code to use one class for the other ?
<html>
      <head>
            <title>A Simple Class</title>
      </head>
      <body>
            <jsp:useBean id="myBook" class="com.wrox.library.BookNew" />
            <jsp:setProperty name="myBook" property="title" value="Begining JSP Web Development" />
            Book Title: <jsp:getProperty name="myBook" property="title" />
            
      </body>
</html>

Open in new window

<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>

Open in new window

0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37802276
It decided to work now. Someone things this sometimes happens because of network issues etc.

brb
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37802283
i will test your code noe...
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 37802293
This was smart way of checking Book class.

Thanks,

Mike
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 37802306
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.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now