Forms instrumentation failed - javac2 in Ant build [Solved (ad hoc)]

Answered

Trying to get Ant build to work but it fails with

Class not found: javax.swing.JPanel

in javac2 on first .form file it attempts to instrument.

I can build and run from IDE just fine (IDEA 2017.3.3 CE).

Generated build.xml must be missing something but I cannot figure out what it is. Or is JDK 9 not supported by Ant yet?

0
5 comments

Does it work if you use Java 8? Similar issues which may be related: https://youtrack.jetbrains.com/issue/IDEA-96947https://youtrack.jetbrains.com/issue/IDEA-142749 Please also try if this workaround helps. Please post complete exception if issue is different. Thanks.

0
Avatar
Permanently deleted user

Thanks for the links Andrey

With JDK 1.8 (and 2017.1.5) I was getting a Kotlin exception I couldn't figure out. Managed to sort it out today, now the build reaches javac2 and fails with

Forms instrumentation failed for MyForm.form: ...build.xml:764: Class not found: com.intellij.uiDesigner.core.Spacer

Call stacks are almost identical to issue/IDEA-96947 with both JDK 1.8 and 9. This appears to be a "normal" report from Javac2.instrumentForms() when it can't find classes, so it looks like I'm just missing classes, though from different packs.

I would actually prefer to keep the project on JDK 1.8, just need to fix missing intellij classes then. Should build.xml reference form_rt.jar ? Neither of mine have it mentioned anywhere.

 

On a separate note, with JDK 9 the missing piece is java.desktop.jmod, and in build log I can actually see a bunch of class path entries being dropped, including:

dropping D:\<project-root>\C:\Program Files\Java\jdk-9.0.4!\java.desktop from path as it doesn't exist

This probably calls for an issue report.

0
Forms instrumentation failed for MyForm.form: ...build.xml:764: Class not found: com.intellij.uiDesigner.core.Spacer

Try to add the forms_rt.jar from IDE_HOME/lib directory to the module dependencies.

0
Avatar
Permanently deleted user

Did that and also added Extracted directory for the app artfact, and now it works.

But is this an intended way? Expected Ant generator to set up all things necessary. After all forms_rt.jar is more of a javac2 dependency and I can build from IDE without adding it.

0

Generated ant script takes classpath from the classpath configured for the project (which is costructed from the dependencies for module you are running). 

You would also need to add this jar to the dependencies if you select Generate GUI into: Java source code in Settings(Preferences) | Editor | GUI Designer settings. Otherwise (when you have Binary class files option set there) when you build from IDE it instruments java sources automatically and binds them to GUI form - and it does not require to have forms_rt.jar in classpath.

0

Please sign in to leave a comment.