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
posted
0
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
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:\
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
posted
0
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
posted
0
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
posted
0
Hi All, Thanks for that detailed explanation.This forum helps alot. Thanks, Mubeen Shaik.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: How to compile this? ( Classpath problem)