Results 1 to 6 of 6

Thread: Error in Java file: Cannot find symbol

  1. #1
    Join Date
    Jan 2009
    Posts
    79

    Error in Java file: Cannot find symbol

    I am getting some error in Java file when i am trying to compile a program that defines an object of another class from a .java file. At the same time i have also tried to add a main method to the class and i have also try to define an object and then successfully compiled that separate file, but when I try to run it I get a runtime exception that says: "Exception in thread "main" java.lang.NoClassDefFoundError". I know the problem is not in the program itself because the entire program compiled and ran seemingly without any kind of error on a different computer, so there must be some sort of problem with my computer. Thanks in advance for any help.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Error in Java file: Cannot find symbol

    Majority of the time you get this error message because you have made some spelling mistake in the name of the class or it might happen that the programmer has not imported the class name. This might one of the reason because of which you are getting this message. If you thinking everything is workign proper then i would suggest you to post the code so that i can help you to overcome from this message.

  3. #3
    Join Date
    Jan 2009
    Posts
    79

    Cannot find symbol in Java

    I had a check for it there is no spelling mistake in the name of the class and i am trying to run the following code

    Code:
    class UsingExceptions
    throwException(); 
    
    code
    public class UsingExceptions
    { 
    public static void main( String args[] )
    {
    try
    {
    throwException(); 
    } 
    catch ( Exception exception )
    {
    System.err.println( "Exception handled in main" );
    } 
    } 
    
    public static void doesNotThrowException()
    {
    try 
    {
    
    System.out.println( "Method does not ThrowException" );
    } 
    catch ( Exception exception ) 
    {
    System.err.println( exception );
    } 
    finally 
    {
    System.err.println( "finally executed in doesNotthrowException" );
    } 
    
    System.out.println( "End of method doesNotThrowException" );
    } 
    
    public static void throwExceptionB() throws Exception
    {
    try 
    {
    System.out.println( "Method throwExceptionB" );
    throw new Exception(); 
    }
    catch ( Exception exception ) 
    {
    System.err.println(
    "Exception handled in method throwException" );
    throw exception;
    
    }
    finally 
    {
    System.err.println( "finally executed in throwException" );
    } 
    
    } 
    
    
    {
    try 
    {
    System.out.println( "Method throwException" );
    throw new Exception(); 
    } 
    catch ( Exception exception ) 
    {
    System.err.println(
    "Exception handled in method throwException" );
    
    
    } 
    finally 
    {
    System.err.println( "finally executed in throwException" );
    } 
    
    } 
    
    
    public static void throwExceptionNullPointer() throws Exception
    {
    try 
    {
    System.out.println( "Method throwException" );
    throw new Exception(); 
    } 
    catch ( Exception exception ) 
    {
    System.err.println(
    "Exception handled in method throwException" );
    throw exception; 
    
    } 
    finally
    {
    System.err.println( "finally executed in throwException" );
    } 
    
    } 
    
    
    public static void throwExceptionIO() throws Exception
    {
    try 
    {
    System.out.println( "Method throwException" );
    throw new Exception(); 
    } 
    catch ( Exception exception )
    {
    System.err.println(
    "Exception handled in method throwException" );
    throw exception; 
    
    }
    finally 
    {
    System.err.println( "finally executed in throwException" );
    } 
    
    } 
    
    }

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Error in Java file: Cannot find symbol

    I guess you are getting an error as cannot find symbol because in throwException method, you have blocked it out with a pair of forward slashes //. Try to remove those slash and then try to run your code and i am sure after that you won't be getting any error message as Cannot find symbol in java.

  5. #5
    Join Date
    Feb 2009
    Posts
    96

    Re: Error in Java file: Cannot find symbol

    you are missing a } after
    System.out.println( "End of method doesNotThrowException" );
    }

  6. #6
    Join Date
    Sep 2009
    Location
    Malaysia
    Posts
    2

    Re: Error in Java file: Cannot find symbol

    Quote Originally Posted by Daren View Post
    you are missing a } after
    System.out.println( "End of method doesNotThrowException" );
    }
    yeah.. good one bro

Similar Threads

  1. Cannot find symbol!
    By jackmarrow in forum Software Development
    Replies: 2
    Last Post: 08-03-2010, 10:37 PM
  2. Square Root Symbol In Java
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 27-01-2010, 10:27 AM
  3. Error while compiling: javac= "cannot find symbol"
    By Harper 21 in forum Software Development
    Replies: 5
    Last Post: 07-01-2010, 08:58 AM
  4. Java 11 cannot find symbol
    By Wyvern in forum Software Development
    Replies: 3
    Last Post: 02-09-2009, 01:12 AM
  5. Where can i find Cents symbol in Word and Excel
    By Kamran in forum Windows Software
    Replies: 3
    Last Post: 16-05-2009, 11:47 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,869,110.75557 seconds with 16 queries