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

Thread: Could not find main class error

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Location
    Greeley, CO
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Could not find main class error

    I currently use Eclipse to maintain our Java application. I recently upgraded from Java 6 to Java 7. I updated my Eclipse projects to use the Java 7 .jar files. I can run the application from Eclipse via the Run Configuration. I can also run the Ant build and it completes successfully. When I install the application on my desktop, I receive the "Java Virtual Machine Launcher: Could not find main class..." error. My CLASSPATH is set to ".". I've searched for a resolution for the past 2 weeks without any luck. Any help is much appreciated.

    Thanks,

    Keith Shaffer


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could not find main class error

    When I install the application on my desktop
    Can you explain what "install" means? A properly constructed jar file should work from any folder.
    Is this a problem with using your IDE to build a jar file?

    For debug info: Open a command prompt window, CD to the folder with the jar file and enter:
    java -jar THEJARFILENAME.jar

    copy the full contents of the command prompt window and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Location
    Greeley, CO
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Could not find main class error

    When I run the Ant build, it creates an executable installer. For example: Installer.exe. It writes the installer to the correct mapping location that I have setup within Eclipse. I then go to the location and run the install executable. This executable writes the application executable, XXXX.exe to the correct location and also creates a shortcut on the desktop. When I double click on the desktop icon, I receive the error.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could not find main class error

    Sorry, I've never executed a java program from an .exe. I've always created jar files.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2014
    Location
    Greeley, CO
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Could not find main class error

    Norm, I've only run the application from the .exe. If I were to navigate to the location of the .jar file that holds the main class and execute the following: java -jar BOLO-UI.jar I receive the following error:


    C:\Program Files (x86)\BOLO by P2 Energy Solutions\BOLO UI Development 13.0.0.1\
    bololib>java -jar BOLO-UI.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: com/jidesoft/action/D
    efaultDockableBarHolder
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :800)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:14
    2)
    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 25)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 58)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.ja va:2570)
    at java.lang.Class.getMethod0(Class.java:2813)
    at java.lang.Class.getMethod(Class.java:1663)
    at sun.launcher.LauncherHelper.getMainMethod(Launcher Helper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:486)

    Caused by: java.lang.ClassNotFoundException: com.jidesoft.action.DefaultDockable
    BarHolder
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 366)
    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 25)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 58)
    ... 18 more

    C:\Program Files (x86)\BOLO by P2 Energy Solutions\BOLO UI Development 13.0.0.1\
    bololib>

    The BOLO-UI.jar file has the main class in it.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Could not find main class error

    Exception in thread "main" java.lang.NoClassDefFoundError: com/jidesoft/action/DefaultDockableBarHolder
    Is the: com.jidesoft.action.DefaultDockableBarHolder
    class in the jar file?

    This doesn't sound like a problem with a java source. It looks like a problem with configuring the build tools.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: August 22nd, 2014, 04:16 PM
  2. Error: Could not find or load main class Program, I need help
    By tsuisou in forum Java Theory & Questions
    Replies: 5
    Last Post: August 22nd, 2014, 03:54 PM
  3. Error: Could not find or load main class
    By ARULARASAN in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 9th, 2013, 03:46 PM
  4. Error: Could not find or load main class
    By lijepdan in forum Java Theory & Questions
    Replies: 8
    Last Post: March 22nd, 2013, 04:32 PM
  5. Execution of .jar file: Could not find main class....Error'
    By suyog53 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 14th, 2012, 02:04 PM

Tags for this Thread