Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: cant catch NoClassDefFoundError

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default cant catch NoClassDefFoundError

    Hi.
    This is my code:

        try {
                final BasicService bs;
                final URL codeBase;
                try {
                    bs = (BasicService) ServiceManager.lookup(
                            "javax.jnlp.BasicService");
                    codeBase = bs.getCodeBase();
                    System.out.println(codeBase);
                } catch (UnavailableServiceException ex) {
                    Logger.getLogger(applet.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (Exception catchMe) {
            }

    and i get:

    java.lang.NoClassDefFoundError: javax/jnlp/UnavailableServiceException
    Caused by: java.lang.ClassNotFoundException: javax.jnlp.UnavailableServiceException
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main" Java Result: 1

    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


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: cant catch NoClassDefFoundError

    Can you make a small, complete program that compiles, executes and shows the problem? Including the jnlp file.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: cant catch NoClassDefFoundError

    Quote Originally Posted by Norm View Post
    Can you make a small, complete program that compiles, executes and shows the problem? Including the jnlp file.
    You probably misunderstand me. Everything is working correctly when i am lunching my app using JWS and i know that this is dedicated for this but i'm wondering if there is a way to catch the exception when i am running my app not using JWS (everything is building correctly i just get an exception when i run it).

    Thanks

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: cant catch NoClassDefFoundError

    i just get an exception when i run it
    A small test program would help us see what the code is doing.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. java.lang.NoClassDefFoundError Help
    By dayamoon in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 16th, 2012, 06:03 AM
  2. java.lang.NoClassDefFoundError help?
    By softballfrk13608 in forum Threads
    Replies: 2
    Last Post: March 6th, 2012, 03:22 PM
  3. Java.lang.NoClassDefFoundError
    By mikedflip2006 in forum Exceptions
    Replies: 0
    Last Post: November 21st, 2011, 11:29 PM
  4. java.lang.NoClassDefFoundError
    By nrao in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 08:18 AM
  5. java.lang.NoClassDefFoundError
    By anonymous001 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: January 26th, 2011, 04:41 PM