File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to compile this? ( Classpath problem) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to compile this? ( Classpath problem)" Watch "How to compile this? ( Classpath problem)" New topic
Author

How to compile this? ( Classpath problem)

Mubeen Shaik
Ranch Hand

Joined: Jan 26, 2004
Posts: 67
Hi all,
I am reading Thinking in JAVA and i am trying to compile the following code. It is giving me error on import statement.
Program
==============



==================
Compilation Error

My Classpath is as follows


===========
Please help me in compiling and understanding this program. I am sure that, i am missing something in classpath.
Thanks in advance,
Mubeen Shaik.


Sun Certified Java Programmer
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
If I remember correctly the source code to the Eckels book is delivered uncompiled. There is a supplied build.xml file which compiles everything as long as ANT is installed.
regards
Nigel
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

The classpath is the path a class may be found.
you class com.bruteforce.sitest isn't found in:
C:\com\bruteforce\sitest
but in
C:\
and com\bruteforce\sitest belongs to that, what is found in C:\


http://home.arcor.de/hirnstrom/bewerbung
Mubeen Shaik
Ranch Hand

Joined: Jan 26, 2004
Posts: 67
Hi Nigel,
I have compiled all the programs and created the classes. Still I am getting the same error.Any Help on this?.
Thanks,
Mubeen.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Did you read the output:
class file contains wrong class: com.bruceeckel.simpletest.Test
Please remove or make sure it appears in the correct subdirectory of the classpath
If the classname is Test and the package-declaration is: com.bruceeckel.simpletest.Test you have to put it into a directory x, such that:
x/com/bruceeckel/simpletest/Test.class
is it's location (revert the slashes in mind).
And x has to be in the classpath. (i.e: x=C:\)
Mubeen Shaik
Ranch Hand

Joined: Jan 26, 2004
Posts: 67
Hi Stefan,
Thanks for that. It worked and i have compiled the program. Now in my classpath i have "C:\".
Could you please explain me why it didn't work with this class path
C:\com\bruceeckle\simpletest.
Thanks in advance,
Mubeen Shaik.
Wai Hung
Greenhorn

Joined: Apr 15, 2004
Posts: 23
the directory in classpath is the starting point.If you are importing com.bruceeckle.simpletest.*,
and your classpath have c:\
it will expect the class is in C:\com\bruceeckle\simpletest
but if your classpath is C:\com\bruceeckle\simpletest
then it will expect the class is in C:\com\bruceeckle\simpletest\com\bruceeckle\simpletest.
Mubeen Shaik
Ranch Hand

Joined: Jan 26, 2004
Posts: 67
Hi All,
Thanks for that detailed explanation.This forum helps alot.
Thanks,
Mubeen Shaik.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to compile this? ( Classpath problem)