Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29-08-2009
Member
 
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.
Reply With Quote
  #2  
Old 29-08-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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.
Reply With Quote
  #3  
Old 29-08-2009
Member
 
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" );
} 

} 

}
Reply With Quote
  #4  
Old 29-08-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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.
Reply With Quote
  #5  
Old 02-09-2009
Member
 
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" );
}
Reply With Quote
  #6  
Old 02-09-2009
Member
 
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 10:13 AM.