You can't add the package statement to the source code, unless you move
your class definition into a directory that matches the package
statement. So try creating a directory called atreides, and within that
a directory called hello, and place the source file and .class file
there. Then put the directory containing atreided in your CLASSPATH,
then either import atreides.hello.* or run java
atreides.hello.HelloWorldSwing
thufir - 15 Jan 2005 19:57 GMT
> You can't add the package statement to the source code, unless you move
> your class definition
Does class definition refer to whether a class is
public/private/other?
> into a directory that matches the package
> statement. So try creating a directory called atreides, and within that
> a directory called hello, and place the source file and .class file
> there. Then put the directory containing atreided in your CLASSPATH,
> then either import atreides.hello.* or run java
> atreides.hello.HelloWorldSwing
////////////////command line///////////////
C:>javac
-classpath C:\java\sources\atreides\hello\
HelloSwing.java
error: cannot read: HelloWorldSwing.java
///////////////command line//////////////////
My directory's are in order, I believe. I'm reading
<http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html>,
but am a bit fuzzy as to the distinction between the
classpath, cp and sourcepath switches for javac.
Thanks,
Thufir Hawat
thufir - 15 Jan 2005 20:11 GMT
///////////////command line///////////////////////
C:\java\sources>javac atreides/hello/HelloSwing.java
C:\java\sources>java atreides.hello.HelloSwing
///////////////command line///////////////////////
The above works :)
How would I do it with the -classpath, or, more importantly, why?
thanks,
Thufir Hawat
klynn47@comcast.net - 16 Jan 2005 02:07 GMT
When I said import the package, that would be in the case where you
create an instance of the class HelloWorldSwing inside another class.
In that case, you would make sure that the directory containing
atriedes is in your CLASSPATH