The textbook I am using says that with
Java 7 the CLASSPATH doesn't have to be defined. Is this true? I haven't had much luck importing any packages I have created myself. This makes me think I should have CLASSPATH defined, and that I am misinterpretting what the textbook is saying.
Also, the
Oracle Java Tutorials say that you can store source and class files in seperate directories. Their example is:
<path_one>\sources\com\example\graphics\Rectangle.java
<path_two>\classes\com\example\graphics\Rectangle.class
I am using Windows. Let's say that I keep all my Java source and class files in 'My Documents\Java' folder. The path I see at the top of the My Documents/Java window is C:\Documents and Settings\SKF\My Documents\Java. Does this mean, using the Oracle Java Tutorials example, that <path_one> and <path two> on my machine would both be C:\Documents and Settings\SKF\My Documents\Java?
If I organized my souce and class files in seperate folders, as suggested in the tutorials and using their Rectangle example, the paths to each would be:
C:\Documents and Settings\SKF\My Documents\Java\sources\com\example\graphics
C:\Documents and Settings\SKF\My Documents\Java\classes\com\example\graphics
Assuming I have created the 'sources', 'classes', 'com', 'example', and 'graphics' folders, if I am going to use the CLASSPATH environment variable, should it be defined (in the edit window of the Environment Variable window) as
C:\Documents and Settings\SKF\My Documents\Java\sources;C:\Documents and Settings\SKF\My Documents\Java\classes
And then, whenever I create other classes that import Rectangle (no matter where the source files for these classes I create are when they get compiled) should all I need to include in the import statement be
and I can assume the compiler will find the Rectangle class?
If I have a source file called Shapes.java in a folder like C:\Documents and Settings\SKF\My Documents\Java\sources\com\example\graphics and it imports Rectangle (which is in C:\Documents and Settings\SKF\My Documents\Java\classes\com\example\graphics) should the Shapes.java file be able to access the Rectangle.class file when it gets compiled?