[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

cannot resolve symbol

Posted on 2012-04-02
12
Medium Priority
?
742 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
Independent Software Vendors: 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!

 
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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

650 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