Results 1 to 6 of 6
- 10-25-2010, 08:50 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 13
- Rep Power
- 0
Error compiling java subclass from command prompt
Good Afternoon,
I have been trying for about an hour to compile two java subclass for the Command Prompt. All of the classes are in the same directory.
The classes are as follows:
Java Code:Book.java - the superclass ChildrenBook.java - a subclass of Book TechnicalBook.java - a subclass of Book.
All of the files are saved under this folder:
This is the command I am running at the command prompt:Java Code:C:\tomcat\webapps\begjsp-ch07\WEB-INF\classes\com\wrox\library
Java Code:javac com\wrox\library\Book.java javac com\wrox\library\TechnicalBook.java javac com\wrox\library\ChildrenBook.java
The Book.java class compiles, but when I run the above commands, I get this error message:
Java Code:cannot find symbol symbol: class Book
I have attached my CLASSPATH, the error message, and the all of the java classes.
Please directly me on exactly what is causing this problem. I have a feeling it has to do with my CLASSPATH not being setup properly. I am using Tomcat 6 with jdk 1.6.0_21
Thanks in advance for all of your help.
- 10-26-2010, 06:30 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
First, when you run the command in your command promt you are in C:\tomcat\webapps\begjsp-ch07\WEB-INF\classes, right?
Set the classpath to the current directory ('.')! (or you can use the -classpath/-cp option in javac)
try
(-cp = -classpath)Java Code:javac -cp . com\wrox\library\TechnicalBook.java javac -cp . com\wrox\library\ChildrenBook.java
javac com\wrox\library\Book.java is not necessary
or you can use the wildcard (you do not have to set the classpath AFAIR)
Java Code:javac com\wrox\library\*
- 10-26-2010, 01:07 PM #3
I am sure that it because of classpath.
You better go through
PATH and CLASSPATH (The Java™ Tutorials > Essential Classes > The Platform Environment)Mak
(Living @ Virtual World)
- 10-26-2010, 01:36 PM #4
Member
- Join Date
- Oct 2010
- Posts
- 13
- Rep Power
- 0
Thank for the reply. I want to make sure that I am understanding you right.
First you want me the change the set the CLASSPATH to include the ".". (Please see jpg attachement).
Secondly, yes I did enter the correct path. (Please see my a screen shot of my command from yesterday).
I will take your suggestions you provide and post my results.
Thank for the fast and concise suggestions you provided. I really appreciated.Last edited by littleone; 10-26-2010 at 05:58 PM.
- 10-26-2010, 02:03 PM #5
Member
- Join Date
- Oct 2010
- Posts
- 13
- Rep Power
- 0
Sure enough that was the case.
All I needed to do was to add the "." to the beginning of the CLASSPATH and rerun the javac command along with the path and the two files compiled.
Thanks for the help. I will be back pretty soon bugging you all for more help because I am having problems getting my servlets to work.
- 10-26-2010, 03:45 PM #6
Member
- Join Date
- Oct 2010
- Posts
- 1
- Rep Power
- 0
1. run the command FROM command promt going to --> C:\tomcat\webapps\begjsp-ch07\WEB-INF\classes location.
2. Set the classpath to the current directory ('.').
3.
execute the following
javac -cp . com\wrox\library\TechnicalBook.java
javac -cp . com\wrox\library\ChildrenBook.java
(-cp = -classpath)
4. javac com\wrox\library\Book.java is not requiredLast edited by pranabpradhan; 10-26-2010 at 03:48 PM.
Similar Threads
-
error in the Command Prompt when running a bat file
By bluesagemedia in forum New To JavaReplies: 1Last Post: 10-03-2010, 01:05 AM -
Compiling/Running in Command Prompt
By coke_in_a_can in forum New To JavaReplies: 12Last Post: 05-31-2010, 09:05 AM -
How to return command prompt error message
By raxwer in forum Advanced JavaReplies: 3Last Post: 05-26-2010, 05:15 PM -
running command prompt using java
By xclaim in forum New To JavaReplies: 1Last Post: 01-14-2010, 03:46 AM -
Command Prompt Java
By kelvinsmj in forum New To JavaReplies: 8Last Post: 11-27-2009, 10:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks