more command line woes......
ok - I have 2 copies of a very similar java class called FileStuff - one of them is part of a package called ch10_io the other is not.... I can run the one that is NOT part of the package by typing >java FileStuff. I cannot run the one that is part of the package.
here's the source for both.....
1st the one in the package:
package ch10_io;
import java.io.File;
import java.io.IOException;
importstatic java.lang.System.out;
publicclass FileStuff{
publicstaticvoid main(String args[])throws IOException{
out.print("File system roots: ");
for (File root : File.listRoots()){
out.format("%s ", root);
}
out.println();
for (String fileName : args){
out.format("%n%nnew File(%s)%n", fileName);
File f =new File(fileName);
out.format("toString(): %s%n", f);
out.format("exists(): %b%n", f.exists());
out.format("lastModified(): %tc%n", f.lastModified());
out.format("isFile(): %b%n", f.isFile());
out.format("isDirectory(): %b%n", f.isDirectory());
out.format("isHidden(): %b%n", f.isHidden());
out.format("canRead(): %b%n", f.canRead());
out.format("canWrite(): %b%n", f.canWrite());
out.format("canExecute(): %b%n", f.canExecute());
out.format("isAbsolute(): %b%n", f.isAbsolute());
out.format("length(): %d%n", f.length());
out.format("getName(): %s%n", f.getName());
out.format("getPath(): %s%n", f.getPath());
out.format("getAbsolutePath(): %s%n", f.getAbsolutePath());
out.format("getCanonicalPath(): %s%n", f.getCanonicalPath());
out.format("getParent(): %s%n", f.getParent());
out.format("toURI: %s%n", f.toURI());
}
}
}
now the one that is not part of the package:
import java.io.File;
import java.io.IOException;
importstatic java.lang.System.out;
publicclass FileStuff{
publicstaticvoid main(String args[])throws IOException{
out.print("File system roots: ");
for (File root : File.listRoots()){
out.format("%s ", root);
}
out.println();
for (String fileName : args){
out.format("%n%nnew File(%s)%n", fileName);
File f =new File(fileName);
out.format("toString(): %s%n", f);
out.format("exists(): %b%n", f.exists());
out.format("lastModified(): %tc%n", f.lastModified());
out.format("isFile(): %b%n", f.isFile());
out.format("isDirectory(): %b%n", f.isDirectory());
out.format("isHidden(): %b%n", f.isHidden());
out.format("canRead(): %b%n", f.canRead());
out.format("canWrite(): %b%n", f.canWrite());
out.format("canExecute(): %b%n", f.canExecute());
out.format("isAbsolute(): %b%n", f.isAbsolute());
out.format("length(): %d%n", f.length());
out.format("getName(): %s%n", f.getName());
out.format("getPath(): %s%n", f.getPath());
out.format("getAbsolutePath(): %s%n", f.getAbsolutePath());
out.format("getCanonicalPath(): %s%n", f.getCanonicalPath());
out.format("getParent(): %s%n", f.getParent());
out.format("toURI: %s%n", f.toURI());
}
}
}
I use the same command for each .... do I need to qualify the command for the first version by using the package name somehow?
when I try to run the packaged version I get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: CH10_IO/ch10_io/FileS
tuff
Message was edited by:
thouse

