The code shows compilation with the -cp trigger but not running. Apparently, it cannot find the HashMultimap. Classpath problem?
$ javac -cp google-collect-1.0.jar MultiThing.java
$ java -cp google-collect-1.0.jar MultiThing
Exception in thread "main" java.lang.NoClassDefFoundError: MultiThing
Caused by: java.lang.ClassNotFoundException: MultiThing
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
Could not find the main class: MultiThing. Program will exit.
$ cat MultiThing.java
import java.io.*;
import java.util.*;
import com.google.common.annotations.*;
import com.google.common.collect.*;
public class MultiThing {
public static void main(String[] args) {
Multimap<String, String> wordToFiles = HashMultimap.create();
wordToFiles.put("first", "HELLO");
wordToFiles.put("first", "HALLO");
for (String thing : wordToFiles.get("first")){
System.out.println(thing);
}
}
}
$ ls
google-collect-1.0.jar MultiThing.class com MultiThing.java