I have finally decided to start using packages in my own code. I thought I knew how they work, I've successfully compiled and run many programs written by others that used packages. But I just cant seem to get them to work in code I've written!
for example, consider the following source code:
package NoLDS.webstrms;
public class ServerStream
{
.
.
.
}
saved as a file "C:\NoLDS\webstrms\ServerStream.java" (win2k)
I open dos and type:
C:\>set classpath=C:
C:\>cd C:\NoLDS\webstrms
C:\NoLDS\webstrms>javac ServerStream.java
C:\NoLDS\webstrms>java ServerStream
Exception in thread "main" java.lang.NoClassDefFoundError: ServerStream (wrong name: NoLDS/webstrms/ServerStream)
.
.
.
didn't work, so then I change the package info in the source to:
package webstrms;
public class ServerStream
{
.
.
.
}
save the file in the same directory, same name.
then I open dos and type:
C:\>set classpath=C:\NoLDS
C:\>cd C:\NoLDS\webstrms
C:\NoLDS\webstrms>javac ServerStream.java
C:\NoLDS\webstrms>java ServerStream
Exception in thread "main" java.lang.NoClassDefFoundError: ServerStream
what is going on? If I take the package declaration out and set the classpath to "C:\NoLDS\webstrms" everything works perfectly.
thanks in advance,
-guy
for example, consider the following source code:
package NoLDS.webstrms;
public class ServerStream
{
.
.
.
}
saved as a file "C:\NoLDS\webstrms\ServerStream.java" (win2k)
I open dos and type:
C:\>set classpath=C:
C:\>cd C:\NoLDS\webstrms
C:\NoLDS\webstrms>javac ServerStream.java
C:\NoLDS\webstrms>java ServerStream
Exception in thread "main" java.lang.NoClassDefFoundError: ServerStream (wrong name: NoLDS/webstrms/ServerStream)
.
.
.
didn't work, so then I change the package info in the source to:
package webstrms;
public class ServerStream
{
.
.
.
}
save the file in the same directory, same name.
then I open dos and type:
C:\>set classpath=C:\NoLDS
C:\>cd C:\NoLDS\webstrms
C:\NoLDS\webstrms>javac ServerStream.java
C:\NoLDS\webstrms>java ServerStream
Exception in thread "main" java.lang.NoClassDefFoundError: ServerStream
what is going on? If I take the package declaration out and set the classpath to "C:\NoLDS\webstrms" everything works perfectly.
thanks in advance,
-guy