Hello,
I have another question regarding packages
Please consider this code:
package com.peter.foo;
public class Bar {
public void invoke() {
System.out.println("Invoking Bar.invoke()-Methode");
}
public static void main(
String[] argv) {
System.out.println("Invoking Bar.main()");
}
}
Compiled with statement: „javac -d c:\jdk1.3\demo\packages Bar.java“
Compiled package Bar.class was put into directory
„c:\jdk1.3\demo\packages\com\peter\foo“.
Now I want to call method „invoke() from program Bartest.java
import com.peter.*;
class Bartest {
public static void main (String args[]) {
Bar b1 = new Bar();
b1.invoke();
}
}
When I compile Bartest.java I receive error messages as follows:
> cd c:\jdk1.3\bin
> javac Bartest.java
c:\jdk1.3\bin>javac Bartest.java
Bartest.java:2: package com.peter does not exist
import com.peter.*;
^
Bartest.java:6: cannot resolve symbol
symbol : constructor Bar ()
location: class Bar
Bar b1 = new Bar();
^
Bartest.java:7: cannot resolve symbol
symbol : method invoke ()
location: class Bar
b1.invoke();
^
3 errors
It seems that Bartest.java cannot locate the package com.peter.foo
WHY? What must I do to properly compile this program?
Thanks for your answers.
Thomas