How to fix NoSuchMethodError in com/sun/tools/javac/ when running unit tests

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

Problem

My unit test fails with NoSuchMethodError somewhere in com/sun/tools/javac/…​ but it runs OK inside NetBeans runtime.

Taken from nbdev-mailing list:

Hi,

I have a code that analyzes content of Java source file (generated R.java) in one of nbandroid plugin
(http://kenai.com/projects/nbandroid/sources/mercurial/content/grammars/src/org/netbeans/modules/android/grammars/ProjectRefResolver.java?rev=609).
It worked fine and I was interested in VariableName.getSimpleName() value.
Now I added VariableName.getConstant() and my unit test fails with NoSuchMethodError somewhere in com/sun/tools/javac/...
but it runs OK inside NetBeans runtime.

I suspect this is because my code is compiled against NetBeans' version of
javac but the test runs with classes from tools.jar shipped with JDK. Is this
correct? How do I fix that (I want running code *and* running test)?

-Radim

Solution

Please try to add: requires.nb.javac=true into the nbproject/project.properties of that project. jlahoda