This discussion is archived
6 Replies Latest reply: Dec 15, 2008 7:08 PM by 807581 RSS

Cannot load custom Swing component

807581 Newbie
Currently Being Moderated
Hi, I have an existing desktop application where there are quite a few custom Swing components in use. There's not been an issue before with these components (past 2 yrs).... until today :-). I opened my IDE (Java Studio Enterprise 8.1) and began work on an existing JPanel only to find all kinds of errors on the panel. Here is what I'm seeing along with setup details:

1) Existing panels will not load without errors referring to classpath issues indicating that the custom components on the panel cannot be found.
2) Custom component(s) cannot be added to a newly created clean JPanel. The following message is given: "Cannot load component class <class name> from Project: <project name>. The class must be compiled and must be on the classpath of the project this form belongs to."
3) I've checked the class path >5 different times with various configurations and find no obvious issues. The custom components are part of the project. I've even put the projects classes output folder in the project compile class path but to no avail. Also the project compiles cleanly without issues.
4) I've removed Java Studio and reinstalled it but still get the same error.
5) JDK = 1.6
6) Source level = 1.6

I'm not sure what else to do. Help please.

Regards,
Daniel
  • 1. Re: Cannot load custom Swing component
    807581 Newbie
    Currently Being Moderated
    4) I've removed Java Studio and reinstalled it but still get the same error.
    Have you also ensured that you are not reusing the user directory from previous install? Please take a look at http://blogs.sun.com/karthikr/entry/jse_directories

    If it does not help, are there any error messages in the ide log file (found at <userdir>/var/log/messages.log)?

    - Have you considered using NetBeans as an alternative to JSE8.1. From http://forum.java.sun.com/thread.jspa?threadID=5192837 :
    Java Studio Enterprise 8.1 is itself built on top of NetBeans version 5.0. NetBeans is an ide developed as opensource at www.netbeans.org; it is extensible ide and so add-on modules can be developed to run on top of netbeans. And that is what JSE8.1 does; JSE 8.1 is NetBeans 5.0 plus several add-on modules (like UML etc).
     
    The latest stable version of NetBeans is 5.5.1 and NetBeans 6.0 is currently under development with milestone 10 being the latest release.
     
    Home page: www.netbeans.org
    Download: http://www.netbeans.info/downloads/index.php (From the main page, you can also download several packs which are addons that provide various functionality).
    Docs: http://www.netbeans.org/kb/index.html
    Docs on EE apps: http://www.netbeans.org/kb/trails/java-ee.html
    Further community resources (mailing lists, issue tracking etc) : http://www.netbeans.org/community/index.html
    wiki.netbeans.org
     
    NetBeans download is free. And since it is developed as an opensource project, the source is freely available under CDDL license.
  • 2. Re: Cannot load custom Swing component
    807581 Newbie
    Currently Being Moderated
    Thanks KarthikR,

    Your reply sparked me to go check the message logs and indeed I found the error. Root cause: I was using JDK 1.5 as my default but compiling one of the custom component projects under JDK 1.6. So when the IDE tried to reload the Custom component it was failing with the message I described but in the logs there were "java.lang.UnsupportedClassVersionError: Bad version number in .class file" exceptions all over the place! A little digging on that error and I had my solution. Migrated the default JDK the IDE uses to 1.6 and things are back to normal! Thanks again for the reply I really appreciate it!

    Regards,
    Daniel
  • 3. Re: Cannot load custom Swing component
    807581 Newbie
    Currently Being Moderated
    I received the same message, even after installing a clean Netbeans 6.1. Running the "Clean and Build Main Project" command in the Build menu fixed it.
  • 4. Re: Cannot load custom Swing component
    807581 Newbie
    Currently Being Moderated
    This is my first NetBeans project so I thought I'd share my lessons learned.

    I too was unable to add Beans from the palette. The error message said that the class was not in the project's classpath.
    I looked in the messages log (located in Userdir/var/log) and saw this same error "java.lang.UnsupportedClassVersionError: Bad version number in .class file".
    You can see your Userdir from the 'About' item in the 'Help' menu.

    My fix was to use 1.6 as my platform and do a rebuild.
    The IDE does not let you change platforms dynamically so you have to shut down and edit a config file.
    In order to specify a different platform you can edit this config file <NetBeansHome>/etc/netbeans.conf

    "netbeans_jdkhome" specifies the platform.

    This is my setting
    netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_10"

    Hope this saves someone the 4 hours that I spent.
  • 5. Re: Cannot load custom Swing component
    807581 Newbie
    Currently Being Moderated
    Same problem. Did a clean and build of the project. It worked! Thanks guys. :D
  • 6. Re: Cannot load custom Swing component
    807581 Newbie
    Currently Being Moderated
    ...to add to the last post: I changed to 1.6 as well Before doing the clean and build. Problem solved!