Hi,
I bought myself Thinking in Java, 3rd Edition, but did not get the cd with (Tried but failed to explain to the chinese shop assistant ), so I got myself the excersizes from the internet.
I am coding in EditPlus, as I believe when one try learn a new language, you should do as much of the dirty work yourself.
However, I got no idea how to work with the supplied excersizes. It got folders named c02 to c15, and the com, frogbean and jcsc folders.
In for instance an excersize in c03 named called EqualsMethod.java, there will be an import line like "import com.bruceeckel.simpletest.*;" This class is in the com folder (com\bruceeckel\simpletest)
How do I compile this sample excersizes in the chapter folders, that import stuff in the com directory?
I'm a newbie, especially with this kind of stuff. Just know some basic Java
You can extend functionality, implement functionality, or in your case you can import them.
You need to store the class in a specific folder...If I remember right it's recommended that you store it in the com.java folder, and when you import it will look something like this:
Hope you don't mind, but I attached the full source code that comes with the book (allthough I had to download it from the net like I said before)
I went throught the first 2 chapters of the book pretty fast, and then the guy start with the excersizes. These sample files use lines like "import com.bruceeckel.simpletest.*;" in a class in say folder "c03".
As you can see, there's all kind of "build" xml files, and some others, and using this is not explained in the book so far. I suppose this guy were using some IDE, not a text editor and cmd line like me.
Saying all this I want to seperate my code too. Nest classes with functionality in folders (Say //SSDev/IO/..., //SSDev/Graphic/...) and then let classes in folders outside use that functionality.
The more I talk (which is too much) I genuinely think I must go back and look at compiler options for JAVAC....that should be where you specify what path's to include?
My english kind of suck (ain't got not mother tongue no more!), so sorry for any misunderstandings
No need to worry about english. It's my native language and still foreigners speak it better than me!
Anyways, this is working for me:
import com.bruceeckel.simpletest.*;
That imports all files in the simpletext directory. If you did something like this:
import com.bruceeckel.simpletest.Test;
It would import only the test file.
Also, your problem could be not adding the package statement in the classes you want to import:
For instance, in the Test class you MUST have this statement:
package com.bruceeckel.simpletest;
I think this is what you're missing, but I could be wrong.
Let me know if there's something I'm not understanding, or you need more help.
PS: There's no need to set the classpath over. It should point to the parent directory, and nothing more.