Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant catch NoClassDefFoundError

 
Mike Kowalski
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
This is my code:



and i get:



I know that this code will only work when i lunch my app using JWS, but is there a way to catch the exception if i lunch my app using jar archiwe? I need this to find out if user is lunching my app localy (using jar archiwe) instead of lunching it through jnlp file.

Thank you very much for your time
 
Jacob Anawalt
Ranch Hand
Posts: 64
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NoClassDefFoundError seems to be uncatchable because you get tripped up twice. First javax.jnlp.ServiceManager.lookup triggers the NoClassDefFoundError, but the enclosing try/catch also contains an undefined class, javax.jnlp.UnavailableServiceException.

Since those are Errors, it is generally discouraged to try and catch them anyway, so lets find another way.

I don't know the canonical way of testing if Java Web Start is active or not, but using java.lang.Class.forName seems like a good way to throw a java.lang.ClassNotFoundException instead.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic