aspose file tools*
The moose likes JNLP and Web Start and the fly likes cant catch NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "cant catch NoClassDefFoundError" Watch "cant catch NoClassDefFoundError" New topic
Author

cant catch NoClassDefFoundError

Mike Kowalski
Greenhorn

Joined: Apr 21, 2013
Posts: 4
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

Joined: Oct 27, 2010
Posts: 32

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.




Jacob
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cant catch NoClassDefFoundError
 
Similar Threads
Can JNLP be used to start a browser, in an application that's not Java Web Start?
java.lang.NoClassDefFoundError
weblogic 10 web service Standalone client issue
Double-download of JNLP download=lazy jars
Strange Problem in Running Jar!