Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I'm stumped
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Thu Nov 17, 2005 5:54 pm   Post subject: I'm stumped

My program compiles fine, but I get:

code:
Exception in thread "main" java.lang.NoClassDefFoundError: Test


When I run it, and I can't see any of the usual causes of this problem.

Java:
public class Test {
   public static void main(String[] args) {
      String[] testArray = {"hello", " ", "world"};

      System.out.println(concat(testArray));
   }

   static String concat(String[] arr) {
          return Fold.foldLeft(arr, "", new Function<String, String>() {
             public String apply(String a, String b) {
                return a + b;
             }
      });
   }
}

interface Function<I, O> {
   public O apply(O a, I b);
}

class Fold {
   public static <I, O> O foldLeft(I[] arr, O initialValue, Function<I, O> func) {
      for (I x : arr)
         initialValue = func.apply(initialValue, x);

      return initialValue;
   }
}
Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: Thu Nov 17, 2005 10:30 pm   Post subject: (No subject)

Err... compiles and runs fine for me. jdk1.5.0_05 & jre1.5.0_05
MysticVegeta




PostPosted: Thu Nov 17, 2005 10:46 pm   Post subject: (No subject)

oh I get the same error, maybe I need to upgrade mine to jdk1.5
wtd




PostPosted: Thu Nov 17, 2005 10:47 pm   Post subject: (No subject)

beard0 wrote:
Err... compiles and runs fine for me. jdk1.5.0_05 & jre1.5.0_05


Same here.
Hikaru79




PostPosted: Thu Nov 17, 2005 11:25 pm   Post subject: (No subject)

Works fine here. If you're doing this in Windows, make sure you run it with
code:
java -cp . Test
. The current directory isn't in the classpath by default. You can also set an environment variable to fix this if you don't want to set it every time.
wtd




PostPosted: Thu Nov 17, 2005 11:32 pm   Post subject: (No subject)

Hikaru79 wrote:
Works fine here. If you're doing this in Windows, make sure you run it with
code:
java -cp . Test
. The current directory isn't in the classpath by default. You can also set an environment variable to fix this if you don't want to set it every time.


Excellent.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: