This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 154197 - Better description of errors due to loading classes from a newer JDK
Summary: Better description of errors due to loading classes from a newer JDK
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
: 216636 230644 267739 (view as bug list)
Depends on:
Reported: 2008-12-01 08:24 UTC by genericprodigy
Modified: 2016-09-01 09:09 UTC (History)
3 users (show)

See Also:
Exception Reporter:

messages.log (42.54 KB, text/plain)
2008-12-01 13:19 UTC, Peter Pis
Log file from genericprodigy. (263.55 KB, text/plain)
2008-12-02 14:02 UTC, genericprodigy

Note You need to log in before you can comment on or make changes to this bug.
Description genericprodigy 2008-12-01 08:24:37 UTC
Working with a Java SE 6 project in the visual designer has "show-stopper" flaws in that dragging a JDK 6 generated
visual component onto a JDK 6 generated JFrame (as an example) has a "Cannot Load Component Class", which usually occurs
if the component is not in the class path, or if the project is not compiled. 

If the class is in the same folder / package as the main frame, and if the project fully compiles, this still comes up
with the same error and will not add the visual component to the frame, rendering the ability to create custom
components in the visual designer inaffective.

I have tested this on Mac OS X and Windows XP Pro, both with the latest updates. Mac OS X is the only operating system
where this issue happens so far and I have tested it on JDK 5 formatted code and, in this case, it works perfectly, so
it seems a Netbeans 6.5 incompatibility on the Mac OS X with JDK 6.
Comment 1 Jiri Vagner 2008-12-01 09:37:59 UTC
Thank you for your report. Are you using official apple java 1.6 on macosx 10.4 or ported java 1.6 aka Soylatte on macosx
Comment 2 genericprodigy 2008-12-01 09:42:34 UTC
I'm using the official Apple SDK on Leopard.
Comment 3 genericprodigy 2008-12-01 09:48:54 UTC
So Mac OS X 10.5.5.
Comment 4 Peter Pis 2008-12-01 13:19:47 UTC
Created attachment 74343 [details]
Comment 5 Peter Pis 2008-12-01 13:24:40 UTC
Product Version: NetBeans IDE Dev (Build 200812010201)
Java: 1.6.0_07; Java HotSpot(TM) 64-Bit Server VM 1.6.0_07-b06-57
System: Mac OS X version 10.5.5 running on x86_64; MacRoman; en_US (nb)
Userdir: /netbeans/70/user

1. Open j2se project.
2. Create new jFrame.
3. Create new jPanel. (Don't compile)
4. Select panel and add it into Palette.
5. Drag the panel from Palette into the frame => "Cannot load component class a.NewJPanel from project: ..."
6. Compile project. Everything works fine now.

To reporter: can this be your case? Does compiling project resolve the issue?
Comment 6 genericprodigy 2008-12-01 14:53:57 UTC
This is quite like my issue. I did add it to the panel but this did not resolve my issue. As stated previously,
compiling does not resolve the issue either - in that case it wouldn't be much of an issue.
Comment 7 genericprodigy 2008-12-01 14:58:03 UTC
I meant palette rather than panel.

But the same issue still occurs.
Comment 8 Peter Pis 2008-12-02 11:39:00 UTC
Please try to compile entire project - select project root and invoke "Build" popup menu action. Then everything should
work as expected. Please confirm this. Thanks in advance.
Comment 9 genericprodigy 2008-12-02 12:12:38 UTC
I tried that and still the same result. 

In project properties the Source/Binary format is set to JDK 6 as well. This seems to be the property that makes the
Comment 10 Jiri Vagner 2008-12-02 12:44:37 UTC
Please, attach your messages.log, file is located inside nb userdir ( {netbeans-user-dir}\var\log\messages.log ) Maybe
log file will help us to find what is wrong.

We are able to use nb 6.5 form designer to design and use custom component on macosx 10.5 and jdk 6 and on mac os x 10.4
using jdk 1.5. From our point of view there is no data loss or critical usability problem, that is why I set priority to P3.
Comment 11 Peter Pis 2008-12-02 12:55:47 UTC
I've changed "Source/Binary Format" to "JDK 1.6" and it works either.
Comment 12 genericprodigy 2008-12-02 14:02:24 UTC
Created attachment 74409 [details]
Log file from genericprodigy.
Comment 13 genericprodigy 2008-12-02 14:03:56 UTC
Product Version: NetBeans IDE 6.5 (Build 200811100001)
Java: 1.5.0_16; Java HotSpot(TM) Client VM 1.5.0_16-133
System: Mac OS X version 10.5.5 running on i386; MacRoman; en_GB (nb)
Userdir: /Users/pjlaszkowicz/.netbeans/6.5
Comment 14 genericprodigy 2008-12-02 14:24:39 UTC
Could it be the fact that my default version of Java on my machine is still 5? That really shouldn't matter though as
NetBeans has asked what version of Java I'm using for that particular application.
Comment 15 Jiri Vagner 2008-12-03 10:47:22 UTC
I think, that you are right. There is something wrong with JDKs. Form is innocent! :D It looks like that classes are
build by j6 compiler but used by j5 runtime. Or something like this. All troubles are caused by ...

>>> Caused: java.lang.UnsupportedClassVersionError: Bad version number in .class file ...
Comment 16 genericprodigy 2008-12-03 11:56:09 UTC
Is this something to be fixed in NetBeans then? As it seems to be an anomoly of the IDE rather than the fact the
developer should be changing his/her default runtime.
Comment 17 Tomas Pavek 2008-12-03 12:47:54 UTC
So if you run NetBeans on Java 5 but compile your project in Java 6 (with binary format set to Java 6) then this 
cannot work. Java 5 can't load classes from Java 6 (with higher version). Nothing can be done with that. Form editor 
could just be more helpful providing a hint what might be the problem.
Comment 18 genericprodigy 2008-12-03 14:16:24 UTC
Yes, I think that is the only solution then. Can a change be made as part of this then? Just to give a better hint; I'll
change my default instance of Java to 6 (I assume that's the recommended solution).
Comment 19 Peter Pis 2008-12-03 15:16:48 UTC
Changing to enhancement.
Comment 20 Tomas Pavek 2012-08-17 16:28:39 UTC
As reports of bug 216636 show, this may manifest not only in form opening, or adding a component, but also in binding support:

java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(
        at java.lang.ClassLoader.defineClass(
        at java.lang.ClassLoader.defineClass(
        at org.netbeans.modules.form.project.ProjectClassLoader.findClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at org.netbeans.modules.form.project.FormClassLoader.findClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(
        at java.lang.Class.forName0(
        at java.lang.Class.forName(
        at org.netbeans.modules.form.project.ClassPathUtils.loadClass(
        at org.netbeans.modules.form.FormUtils.loadClass(
        at org.netbeans.modules.form.FormUtils.loadClass(
        at org.netbeans.modules.form.BindingDesignSupport.treeToType(
        at org.netbeans.modules.form.BindingDesignSupport.access$200(
        at org.netbeans.modules.form.BindingDesignSupport$
        at org.netbeans.modules.form.BindingDesignSupport$
        at org.netbeans.modules.form.BindingDesignSupport.determineTypeParameter(
        at org.netbeans.modules.form.BindingDesignSupport.determineType(
        at org.netbeans.modules.form.BindingCustomizer$ExpressionNode.(
        at org.netbeans.modules.form.BindingCustomizer.sourceComboActionPerformed(
        at org.netbeans.modules.form.BindingCustomizer.access$1200(
        at org.netbeans.modules.form.BindingCustomizer$FormListener.actionPerformed(
        at javax.swing.JComboBox.fireActionEvent(
        at javax.swing.JComboBox.setSelectedItem(
        at javax.swing.JComboBox.setSelectedIndex(
        at org.netbeans.modules.form.BindingCustomizer.setBindingToUI(
        at org.netbeans.modules.form.BindingCustomizer.setBinding(
        at org.netbeans.modules.form.BindingProperty$BindingPropertyEditor.getCustomEditor(
Comment 21 Tomas Pavek 2012-08-17 16:32:40 UTC
*** Bug 216636 has been marked as a duplicate of this bug. ***
Comment 22 Tomas Pavek 2012-11-09 17:41:20 UTC
This improved slightly by improving the way exceptions from custom classes are reported to the user (bug 83467 and bug 121616), but it would deserve a special detection and reporting to the user.
Comment 23 Tomas Pavek 2012-11-09 17:51:36 UTC
> but it would deserve a special detection and reporting to the user.
...for this specific case of class version mismatch error.
Comment 24 Tomas Pavek 2013-06-03 15:08:16 UTC
*** Bug 230644 has been marked as a duplicate of this bug. ***
Comment 25 Tomas Pavek 2016-09-01 09:01:49 UTC
*** Bug 267739 has been marked as a duplicate of this bug. ***
Comment 26 Tomas Pavek 2016-09-01 09:09:31 UTC
Just to make this quite clear:
The UnsupportedClassVersionError can be avoided by running NetBeans on a newer Java version. There is no other way to fix it.

This enhancement report is here to provide a better error message that would explain that to the user.