On Feb 17, 4:52 am, Cecil Haertel III <[email protected]> wrote:
> Has any done these (especially the classpath ) exercises on Linux (Ubuntu).
> If so can you explain how to get past the last exercise/lab. When you
> introduce the DummyClass object, and import the "anotherpackage" into
> StudentRecord.
>
> Everything worked fine until I did this. Now I can't get past the compile
> phase because StudentRecord throws a class not found error.
>From what you send:
<quote>
package Student;
//import other packages
import anotherpackage.*;
public class StudentRecord {
</quote>
Notice that a package should lowercase and that you name it Student,
so as in the exercise, name it studentpackage.
Rule of thumb, if you put in a directory named foo, a java file named
bar.java, and that the directory foo will serve as a package, you
should have a line in bar.java at the top:
package foo;
Then compile exactly as it is done in the exercise.
It should work.
Except that you will probably have to remove the old class files
beforehand.
That is (adapt to your system), assuming you are in the myjavaprograms
directory:
cd anotherpackage;
rm -f *.class
cd ..
cd studentpackage;
rm -f *.class
cd ..
javac studentpackage/*.java
java -classpath . studentpackage.StudentRecordExample
(rm -f maybe del on your system, the reminder should be the same)
In StudentRecordExample, you have a line:
package Student;
change it to package studentpackage;
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en