?
Solved

cannot resolve symbol

Posted on 2012-04-02
12
Medium Priority
?
729 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
12 Comments
 
LVL 28

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 34

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 28

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 34

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 34

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 28

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

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 28

Accepted Solution

by:
rrz earned 2000 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 34

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 34

Author Comment

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

Author Closing Comment

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

Thanks,

Mike
0
 
LVL 34

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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