Results 1 to 4 of 4
  1. #1
    C.phantasy is offline Member
    Join Date
    Nov 2012
    Posts
    10
    Rep Power
    0

    Default java.lang.ClassNotFoundException - Issue

    Hi Guys!

    Im currently learning how to handle multiple classes, but Im having a rough time with an error.

    Here is my current code for the both classes:

    Tuna.java
    Java Code:
    package client1;
    public class Tuna {
        public void simplemessage(){ 
            System.out.println("Enkelt meddelande");
            
            
        
                }
        }
    Class99.java
    Java Code:
    package client1;
    public class Class99 {
        public static void main(String[] args) {
             Tuna test = new Tuna();
             
             test.simplemessage();
             
    }
    Error Code:
    java.lang.NoClassDefFoundError: client1/Class99
    Caused by: java.lang.ClassNotFoundException: client1.Class99
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 05)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 46)


    Any suggestions on what is wrong with the code I wrote? Or is it something wrong with my Jdeveloper settings?
    Last edited by C.phantasy; 11-04-2012 at 10:36 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java.lang.ClassNotFoundException - Issue

    The exception is saying that the runtime cannot find the client.Class99 class.

    Make sure that the class exists - that is make sure you have compiled both classes. At the moment Class99 has a syntax error and will not compile.

  3. #3
    C.phantasy is offline Member
    Join Date
    Nov 2012
    Posts
    10
    Rep Power
    0

    Default Re: java.lang.ClassNotFoundException - Issue

    Thanks for the reply!

    I have bypassed the current error by making a new project with new classes.

    Here is the new code:

    is.java
    Java Code:
    package client;
    
    public class is {
    
    
        
    
        public static void simplemessage(String name){
           System.out.println("Hej");}
          
        }
    isotop.java
    Java Code:
    package client; 
    
    public class isotop {
        public static void main(String[] args) {
                    
            is olle = new is(); 
            
        
            olle.simplemessage();
            
        }
    
        
        }


    Im using this guys tutorials: Java Programming Tutorial - 14 - Using Multiple Classes - YouTube

    What am I doing wrong? He clearly says in the video to first create an object from the class that will be used in the method.
    I do that by writing "is olle = new is();".

    Then he suggests that I should do "olle.nameofmymethod" which in this case is "olle.simplemessage". But I get this annoying error: simplemessage(java.lang.String) in client.is cannot be applied to ().

    Thanks for your help! If I cant understand this part then I wont be able to continue his videos :-(
    Last edited by C.phantasy; 11-04-2012 at 11:53 PM.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java.lang.ClassNotFoundException - Issue

    Sorry, I don't use JDeveloper. But I think you did the right thing by starting again. It is very annoying when IDEs like JDeveloper try and run a program that has not been compiled - no good can come from that.

    simplemessage(java.lang.String) in client.is cannot be applied to ()
    Basically the compiler is telling you that you have a method simplemessage() that takes a string argument but you are trying to use it without giving it that argument.

    Try:

    Java Code:
    package client; 
     
    public class isotop {
        public static void main(String[] args) {
            is olle = new is(); 
            olle.simplemessage("world");
        }
    }
    Of course you are not doing anything with the string "world", but that's OK. You could do something with it if you wanted to:

    Java Code:
    package client;
     
    public class is {
        public static void simplemessage(String name){
           System.out.println("Hej, " + name);
        }
    }
    -----

    Sorry to be a pest, but there's a couple of things you could be fussy about now - because it'll pay off later. First be very consistent with how you indent code. } should in a line on its own and should line up with the corresponding {. Secondly classes should start with a capital letter, eg Is. The class and the file have to agree so the class client.Is will correspond with the file client\Is.java

Similar Threads

  1. Replies: 0
    Last Post: 03-12-2012, 01:13 PM
  2. Error -- java.lang.ClassNotFoundException
    By dewitrydan in forum New To Java
    Replies: 18
    Last Post: 03-02-2012, 04:25 PM
  3. java.lang.ClassNotFoundException
    By djgovins in forum Java Servlet
    Replies: 4
    Last Post: 07-25-2011, 11:54 AM
  4. Replies: 8
    Last Post: 11-04-2010, 01:46 PM
  5. java.lang.ClassNotFoundException
    By ravian in forum New To Java
    Replies: 1
    Last Post: 01-07-2008, 10:31 AM

Posting Permissions

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