NoClassDefFoundError with Path

From: Peter Bassett (pbassett2223_at_comcast.net)
Date: 02/27/05


Date: Sun, 27 Feb 2005 10:33:56 -0600

My java program ListFiles lists all .jpg files in a folder. It accepts 1
argument, the folder containing the files. When I run this from c:\java
and include the long pathname as the argument, it wokrs fine. But if I
attach to the folder with the .jpgs and try to simply type

ListFiles "thefolder" > output.txt

I get the error
Exception in thread "main" java.lang.NoClassDefFoundError: ListFiles

System variables CLASSPATH is .;c:\java and PATH contains c:\java so I
don't know why I get this error. I thought I can run the program from
any folder.

Thanks,
Pete

FYI here is the code

>>>>
/* usage: cd c:\java; java ListFiles "c:\Documents and Settings\..." >
output.txt */

import java.io.*;
import java.lang.String;

public class ListFiles {

 public static void main(String arg[]) {

ListFiles d = new ListFiles();
 if (arg.length > 0) {
             System.out.println("Digital Photo List from " + arg[0] + "\r\r");
        d.ListImages(arg[0]);
 }
}

 public void ListImages(String dirItem) {
         File file;
         String list[];
        int i=0, j=0;
         file = new File(dirItem);
         if (file.isDirectory()) {
                 list = file.list();
                 for (i=0, j=0; i < list.length; i++) {
                        list[i] = list[i].toLowerCase();
                        if (!list[i].startsWith("tn_") && (list[i].endsWith
(".jpg") || list[i].endsWith(".gif"))) {
                                if (j++ != 0) System.out.println(",");
                                System.out.print("\t\t\"" + list[i].substring(0,
list[i].length()-4) + "\",\t\t\"\"");
                        }
                    }
          }
         System.out.println("\r\r" + j + " images");
 }

}
<<<<



Relevant Pages

  • Re: script to find all files in folder/subfolders
    ... Sub ListFiles (strFolderName) ... WScript.Echo "Folder" & objItem.Name ... Is there a reason you want to use WMI for this? ...
    (microsoft.public.windows.server.scripting)
  • Error running program from a remote folder
    ... I haven't programmed in Java for awhile and forgot how to get this to work. ... I have a program ListFiles developed in c:\java which lists every .JPG and ... It works fine running from that folder. ... argument, the pathname, so a command could be "java ListFiles ." ...
    (comp.lang.java)
  • Problem running from a different folder
    ... I am having a problem running my Java application from a remote folder. ... Yet when from another folder I type "ListFiles .", ... here's ListFiles.java - it lists digital image files in a folder ...
    (comp.lang.java)
  • Re: reading a folder
    ... the File object has a listFiles() method. ... >From there you will get a list of child entries.. ... > I'm trying to use Java to read the contents of my Temporary Internet ... > folder" any ideas how to access the contents of this folder using ...
    (comp.lang.java.programmer)