SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

Exception in thread "main" java.lang.NoClassDefFoundError: CreateMap #284

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, I'm trying to run a sample from this page. It's called CreateMap. But, when 
I try to run it, I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: CreateMap (wrong name
: sample/maps/CreateMap)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: CreateMap.  Program will exit.

I'm pretty sure I set the classpath right, because other classes from the same 
directory work just fine. The build examples work as well. Here is the source 
code:

package sample.maps;

import com.google.gdata.client.*;
import com.google.gdata.client.maps.*;
import com.google.gdata.data.*;
import com.google.gdata.data.maps.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.URL;

public class CreateMap {

  public static void main(String[] args) {
    MapsService myService = new MapsService("createMap");
    try {
     // Replace username and password with your authentication credentials
      myService.setUserCredentials("username","password");
      createMap(myService);
    } catch(AuthenticationException e) {
      System.out.println("Authentication Exception");
    } catch(ServiceException e) {
      System.out.println("Service Exception: " + e.getMessage());
    } catch(IOException e) {
      System.out.println("I/O Exception");
    }
  }

  public static MapEntry createMap(MapsService myService)
    throws ServiceException, IOException {

    // Replace the following URL with your metafeed's POST (Edit) URL
    // Replace userID with appropriate values for your map
    final URL editUrl = new URL("http://maps.google.com/maps/feeds/maps/userID/full");
    MapFeed resultFeed = myService.getFeed(editUrl, MapFeed.class);
    URL mapUrl = new URL(resultFeed.getEntryPostLink().getHref());

    // Create a MapEntry object
    MapEntry myEntry = new MapEntry();
    myEntry.setTitle(new PlainTextConstruct("Demo Map"));
    myEntry.setSummary(new PlainTextConstruct("Summary"));
    myEntry.getAuthors().add(new Person("My Name", null, "username"));

    return myService.insert(mapUrl, myEntry);
  }
}

Thanks in advance.

Original issue reported on code.google.com by Nermin.T...@gmail.com on 22 Jun 2010 at 10:23

GoogleCodeExporter commented 9 years ago
I would just like to add that none of the samples from this page work for me. I 
always get the same error.

Original comment by Nermin.T...@gmail.com on 22 Jun 2010 at 10:54

GoogleCodeExporter commented 9 years ago
I found the problem. It worked after I deleted the package info and added a few 
more classes into the classpath. 

Original comment by Nermin.T...@gmail.com on 22 Jun 2010 at 1:43

GoogleCodeExporter commented 9 years ago

Original comment by yanivin...@gmail.com on 22 Jun 2010 at 7:18