Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

netbeans

If it is Netbeans, try to uncheck "Compile on save" setting in the project properties (Build -> Compiling). This is the only thing which helped me in a similar situation.


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.


It's caused by NetBeans retaining some of the old source and/or compiled code in its cache and not noticing that e.g. some of the code's dependencies (i.e. referenced packages) have changed, and that a proper refresh/recompile of the file would be in order.

The solution is to force that refresh by either:

a) locating & editing the offending source file to force its recompilation (e.g. add a dummy line, save, remove it, save again),
b) doing a clean build (sometimes will work, sometimes won't),
c) disabling "Compile on save" (not recommended, since it can make using the IDE a royal PITA), or
d) simply remove NetBeans cache by hand, forcing the recompilation.

As to how to remove the cache:

If you're using an old version of NetBeans:

  • delete everything related to your project in .netbeans/6.9/var/cache/index/ (replace 6.9 with your version).

If you're using a newer one:

  • delete everything related to your project in AppData/Local/NetBeans/Cache/8.1/index/ (replace 8.1 with your version).

The paths may vary a little e.g. on different platforms, but the idea is still the same.


I also got the same error and I did clean build and it worked.


Add selenium-server-standalone-3.4.0.jar. It works to me. Download Link


Disable Deploy on Save in the Project's Properties/Run screen. That's what worked for me finally. Why the hell NetBeans screws this up is beyond me.

Note: I was able to compile the file it was complaining about using right-click in NetBeans. Apparently it wasn't really compiling it when I used Build & Compile since that gave no errors at all. But then after that, the errors just moved to another java class file. I couldn't compile then since it was grayed out. I also tried deleting the build and dist directories in my NetBeans project files but that didn't help either.


Organize your code as a maven module. Once done run the command from terminal
$mvn installl
to check if your code builds fine.
Finally import the project in netbeans or eclipse as maven project.