Results 1 to 2 of 2
  1. #1
    guerlando is offline Member
    Join Date
    Mar 2016
    Posts
    11
    Rep Power
    0

    Default NoClassDefFoundError while compiling from source

    Please, see what I did in the shell. I just cloned this github repository, compiled it and tried to run, but I get the NoClassDefFoundError error. What's happening? I've searched the internet but explanations are not satisfatory.

    Java Code:
    rafaelp@p:~/teste$ git clone https://github.com/bitletorg/weupnp.git
    Cloning into 'weupnp'...
    remote: Counting objects: 477, done.
    remote: Total 477 (delta 0), reused 0 (delta 0), pack-reused 477
    Receiving objects: 100% (477/477), 180.74 KiB | 143.00 KiB/s, done.
    Resolving deltas: 100% (143/143), done.
    Checking connectivity... done.
    rafaelp@p:~/teste$ ls
    weupnp
    rafaelp@p:~/teste$ cd weupnp/src/main/java/org/bitlet/weupnp/
    rafaelp@p:~/teste/weupnp/src/main/java/org/bitlet/weupnp$ javac *.java
    rafaelp@p:~/teste/weupnp/src/main/java/org/bitlet/weupnp$ ls
    GatewayDevice.class         GatewayDiscover.java                       NameValueHandler.java
    GatewayDeviceHandler.class  GatewayDiscover$SendDiscoveryThread.class  PortMappingEntry.class
    GatewayDeviceHandler.java   Main.class                                 PortMappingEntry.java
    GatewayDevice.java          Main.java
    GatewayDiscover.class       NameValueHandler.class
    rafaelp@p:~/teste/weupnp/src/main/java/org/bitlet/weupnp$ java Main
    Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: org/bitlet/weupnp/Main)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: NoClassDefFoundError while compiling from source

    rafaelp@p:~/teste/weupnp/src/main/java/org/bitlet/weupnp$ java Main
    Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: org/bitlet/weupnp/Main)
    It looks like the class is in a package which means its correct name is: org.bitlet.weupnp.Main not just Main.

    The java program can not find the class file because it expects the full name as an argument:
    java org.bitlet.weupnp.Main
    The classpath must be set to contain the folder that holds the org folder at the start of the path to the Main.class file in the weupnp folder.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Source Not Found compiling error
    By bradjohns94 in forum New To Java
    Replies: 5
    Last Post: 09-03-2012, 12:08 AM
  2. Replies: 0
    Last Post: 01-29-2009, 10:43 AM
  3. Replies: 1
    Last Post: 11-28-2008, 06:27 PM
  4. Help me out in compiling the source code
    By aks.nitw in forum Advanced Java
    Replies: 3
    Last Post: 10-17-2008, 08:33 AM
  5. Error in compiling Firewall source code
    By ajib85 in forum Networking
    Replies: 8
    Last Post: 10-02-2008, 04:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •