• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.NoClassDefFoundError: javax.swing.JPanel?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a Java app throwing this error msg java.lang.NoClassDefFoundError: javax.swing.JPanel. The developer says the swing classes are apparently missing.

Googled the phrase. What I came up with "the class was there at compile time, but not at runtime."
Came up with another hit where the java swing libraries are missing. www.linuxquestions.org/questions/programming-9/missing-java-swing-libraries-134360
So I ran a search and came up with following.

find / -name javax* -print
/usr/lib/jvm/java-7-oracle/lib/missioncontrol/plugins/javax.el_2.2.0.v201108011116.jar
/usr/lib/jvm/java-7-oracle/lib/missioncontrol/plugins/javax.servlet.jsp_2.2.0.v201112011158.jar
/usr/lib/jvm/java-7-oracle/lib/missioncontrol/plugins/javax.servlet_3.0.0.v201112011016.jar

Would the swing libraries be in one of these jar files or am I missing them?
If they are missing. How can I add them?

I'm running java -version.

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should not expect to find classes in packages like javax* to be inside jars with a javax-prefix... Swing classes are inside rt.jar.
 
Marshal
Posts: 79231
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you set a system CLASSPATH? That might prevent you finding those classes.
If not, I would suggest trying reinstalling Java® first. It might not work, but it is easy enough and will only take a few minutes.
 
Jim Armstrong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christian Dillinger wrote:You should not expect to find classes in packages like javax* to be inside jars with a javax-prefix... Swing classes are inside rt.jar.



Thanks for pointing out they're in rt.jar.
 
Jim Armstrong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Have you set a system CLASSPATH? That might prevent you finding those classes.
If not, I would suggest trying reinstalling Java® first. It might not work, but it is easy enough and will only take a few minutes.



We didn't have a classpath set. But thanks for pointing it out.
 
Jim Armstrong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We solved this by adding -Djava.specification.version=1.6 to JAVA_OPTS

The developer suggested that parameter be added to JAVA_OPTS, the app was compiled using version 1.5. He explained that option is intended to set the 1.6 compatibility mode.
 
Campbell Ritchie
Marshal
Posts: 79231
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JAVA_OPTS? Is that a special properties file peculiar to your app? I had never heard of it before.
Code compiled with Java5 should run unchanged on a Java6 runtime.
reply
    Bookmark Topic Watch Topic
  • New Topic