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 3 of 3

Thread: cmd java run issue

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default cmd java run issue

    When I compile my java application in NetBeans there's no problem but when I try to run my application through the command prompt I get the following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: CarInsuranceCalc (wrong name: pkgCarInsuranceCalc/CarInsuranceCalc)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :791)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader. java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:482)


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: cmd java run issue

    The class cannot be found. It looks like your class is a member of a package - be sure you are executing relative to the root of the package. See
    Lesson: Packages (The Java™ Tutorials > Learning the Java Language)

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: cmd java run issue

    I was used javac CarInsuranceCalc.java

    Then java CarInsuranceCalc

    I just tried java pkgCarInsuranceCalc.CarInsuranceCalc

    Now I'm receiving the following:

    Error: Could not find or load main class pkgCarInsuranceCalc.CarInsuranceCalc.class

    (Actually doesn't matter tried the latest command in the src folder and it worked).

Similar Threads

  1. Replies: 2
    Last Post: November 18th, 2012, 02:09 PM
  2. Java Class Excercise (Related to Strings + Cmd Line Arguments)
    By Wwong3333 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 19th, 2012, 09:22 PM
  3. [SOLVED] How to referenc a class file. using only notepad and run cmd.
    By SPACE MONKEY in forum Java Theory & Questions
    Replies: 53
    Last Post: May 14th, 2012, 11:22 PM
  4. Java Issue / Cache issue
    By VisualPK in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 14th, 2012, 08:43 PM
  5. Replies: 7
    Last Post: October 13th, 2011, 03:03 AM

Tags for this Thread