Solved

cannot resolve symbol

Posted on 2012-04-02
12
714 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 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 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 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
Technology Partners: 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 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
 
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 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 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
constructor overloading 2 96
iterator example remove 8 75
eclipse luna javeEE perspecive missing 5 122
running on tomcat not jboss eap 7.0 3 50
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
A big percent of today’s marketing activity is performed through the online environment. The marketing strategies that have existed a decade ago no longer relate to what’s happening today. We’re currently facing a revolutionary era, called the digit…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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