Roland,
Give the package name foobar.Foo to the VM. Otherwise, it's looking
for a file Foo.class in your current directory, but you moved it to
directory foobar.
See trace below.
Vartan
$ pwd
/home/vartan/scratch
$ ls
Bar.java Foo.java README foobar
$ javac *.java
$ ls
Bar.class Bar.java Foo.class Foo.java README foobar
$ mv *.class foobar
$ ls foobar
Bar.class Foo.class
$
$ java foobar.Foo
Foo here
Roland Silver writes:
> I have a problem with packages that has me stumped. I've boiled it
> down to two simple classes, defined in Foo.java and Bar.java; both
> are in the directory /home/rollo/Java/foobar on my i386 Linux machine.
>
> //Foo.java
> package foobar;
> import java.util.*;
> public class Foo {
> public Foo() {
> Bar bar = new Bar();
> }
> public static void main(String[] args) {
> System.out.println("Foo here");
> }
> }
>
> //Bar.java
> package foobar;
> public class Bar {
> public Bar() {
> Foo foo = new Foo();
> }
> }
>
> Current directory is /home/rollo/Java/foobar, and
> CLASSPATH specifies the following three paths:
> /usr/local/jdk117_v3/lib/classes.zip
> /home/rollo/TIJ/exercises
> /home/rollo/Java
>
> The command
> javac Foo.java
> compiles OK, as does
> javac Bar.java
> putting Foo.class and Bar.class in the foobar directory, but
> java Foo
> complains:
> Can't find class Foo
>
> I'd really appreciate it if someone can help me with this problem!
> * What am I doing wrong?
> * How do I fix it?
>
> I am running Blackdown JDK version 1.1.7-V3 on an i386 machine under
> Red Hat Linux 6.0.
>
> -- Roland Silver <[EMAIL PROTECTED]>
>
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]