So I have Java 7 (64bit Windows build 84) and NetBeans 6.8. I want to use the new invokedynamic stuff in Java 7 and compile from NetBeans but I can't figure out how to get NetBeans to run the program with the right options except when I build it (run fails, build works).

The code needs to be compiled with the option -XDinvokedynamic and run with -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic. So, in the Project Properties dialogue, I change the Additional Compiler Options in Build to include -XDinvokedynamic but that only affects the build not when I click run.

I believe adding the -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic options to the VM Options box in Run works correctly though (although I can't be sure).

So, simply how can I get NetBeans to use compile with -XDinvokedynamic whether I'm building or just running it?

Was it helpful?


In NetBeans 6.8, the only way to get this to work is to turn off the Compile on Save option. When Compile on Save is on, the 'Additional Compiler Options' is ignored, silently.

There is a bugzilla entry with more details about the effect of the compile on save property.


In each project's properties, in the compile part you can specify additional compile options like this one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow