File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant catch NoClassDefFoundError

 
Mike Kowalski
Greenhorn
Posts: 6
  • 0
  • 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
  • 0
  • 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.


 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic