Java.Lang.Runtimeexception: Uncompilable Source Code - What Can Cause This

java.lang.RuntimeException: Uncompilable source code - what can cause this?

I guess you are using an IDE (like Netbeans) which allows you to run the code even if certain classes are not compilable. During the application's runtime, if you access this class it would lead to this exception.

Uncompilable source code RuntimeException in netbeans

We finally got a solution, but still don't quite know why the situation occurs. When you have Compile On Save activated, Netbeans generates a second set of class files for debugging etc. These are stored in $USER/.netbeans/var/cache/index/s*/java/*/classes

Somehow (not sure how) this directory can get corrupted or fail to update.

If you close netbeans, delete $USER/.netbeans/var/cache/index and all subdirectories and restart netbeans this clears the cache. If you have no compile errors, your problem ought to go away at this point.

NB: $USER is your user directory - on Windows 7 this is usually c:\Users\username, I guess on Unix it will be ~username.

If you get this problem please vote for, comment on, or add information to: http://netbeans.org/bugzilla/show_bug.cgi?id=182009

Exception in thread main java.lang.RuntimeException: Uncompilable source code - cant find symbol

 package taxreturn;

import java.util.Scanner; // on top

public class TaxReturn {
// only one public class per file

public static final int Single = 1;
public static final int Married = 2;
private static final double Rate1= 0.5;
private static final double Rate2= 0.25;
private static final double Rate3= 0.75;
private static final double Single_Bracket1= 21450;
private static final double Single_Bracket2= 51900;
private static final double Married_Bracket1= 35000;
private static final double Married_Bracket2= 86800;

private double income;
private int status;

public TaxReturn (double anIncome, int aStatus){
income=anIncome;
status = aStatus;
}

public double getTax (){
double tax = 0;

if (status == Single ){
if (income <= Single_Bracket1)

tax = Rate1 * income;
else if ( income <= Single_Bracket2)
tax = Rate1 * Single_Bracket1 + Rate2*(income - Single_Bracket1);
else
tax = Rate1 * Single_Bracket1 + Rate2 * (Single_Bracket2 - Single_Bracket1) + Rate3 * (income - Single_Bracket2);
} // added

else

if (income<= Married_Bracket1)
tax=Rate1 * income;
else if (income <= Married_Bracket2)
tax= Rate1 * Married_Bracket1 + Rate2 * (income -
Married_Bracket1);

else
tax = Rate1 * Married_Bracket1 + Rate2 * ( Married_Bracket2 -
Married_Bracket1) + Rate3 * (income - Married_Bracket2);

// not here }

return tax;
} // ends getTax

} // added, ends class

// import java.util.Scanner; not here
class taxReturnTester {

public static void main (String [] args) {
Scanner in = new Scanner (System.in);
System.out.print("Please Enter your Income:");
double income = in.nextDouble();
System.out.print("Please enter S (single) M (Married): ");
String input = in.next();

// CHECK POINT

System.out.println("Check point1");

int status= 0;

if (input.equalsIgnoreCase("s"))
status= TaxReturn.Single; // upcase
else if (input.equalsIgnoreCase("m"))
status = TaxReturn.Married; // upcase
else
{ // added

System.out.println("Wrong Input. Please do it again");
return;
} // added
TaxReturn aTaxReturn = new TaxReturn(income,status);
System.out.println ("The tax is: " + aTaxReturn.getTax() ); // added space
} // ends main
} // ends class

// not out any classes
// TaxReturn aTaxReturn = new TaxReturn(income,status);
// System.out.println ("The tax is" + aTaxReturn.getTax() );

Exception in thread main java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: javax.swing.JFrame.setContentPaneel

You are using the wrong class name. Paneel does not exist, it should be Panel instead.

Also, the method you are calling is called setContentPane(). See the reference for more information.

Edit: As you can see in the comments on this answer, the problem was in the Panel class (but not as stated above).
Panel has to extend JPanel to allow it to be added to the frame.

Error when invoking method - java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: any

From the code you posted, seems that you're using the wrong character that looks a lot like " but they're not the same. Fix it, recompile the code and try again.

RuntimeException: Uncompilable source code

Delete NetBeans cache ~/.netbeans/6.9/var/cache/index/ (everything inside that folder)

Change 6.9 for your version.



Related Topics



Leave a reply



Submit