Results 1 to 6 of 6
  1. #1
    eLancaster is offline Member
    Join Date
    Jan 2011
    Posts
    93
    Rep Power
    0

    Default main method not found in class

    Check out this main method i wrote. there's nothing wrong with it but for some reason its giving a whole lot of errors. the code and errors are quoted below


    FontOptions_MainClass.java
    Java Code:
    import javax.swing.JFrame;
    public class FontOptions_MainClass {
    	
    	public static void main(String args[])
    	{
    		FontOptions fontApplication = new FontOptions();
    		fontApplication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		fontApplication.setSize(300, 200);
    		fontApplication.setVisible(true);
    		
    	}
    
    }
    ERRORS

    Exception in thread "main" java.lang.NoClassDefFoundError: FontOptions_MainClass
    Caused by: java.lang.ClassNotFoundException: FontOptions_MainClass
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
    Could not find the main class: FontOptions_MainClass. Program will exit.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    It has nothing to do with the main method. It is claiming it can't find the class. try using
    Java Code:
    -cp .
    on the command line.

  3. #3
    eLancaster is offline Member
    Join Date
    Jan 2011
    Posts
    93
    Rep Power
    0

    Default

    wellll...i use eclipse, but i'll give it a go.

  4. #4
    eLancaster is offline Member
    Join Date
    Jan 2011
    Posts
    93
    Rep Power
    0

    Default

    I just checked the folder where all the classes are kept and realized they're all gone. I didn't delete them! they've all just gone. Should i reinstall eclipse?

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by eLancaster View Post
    I just checked the folder where all the classes are kept and realized they're all gone. I didn't delete them! they've all just gone. Should i reinstall eclipse?
    Normally Eclipse keeps the compiled .java files separate from the .java source files (in a ./bin directory and a ./src directory respectively). Also, normally Eclipse keeps those class files up to date. Press Ctrl-Shift-Save to save all of your source files and F5 to refresh all of your class files. Does that work?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    eLancaster is offline Member
    Join Date
    Jan 2011
    Posts
    93
    Rep Power
    0

    Default

    No, that didn't work, but i managed to get it working by making a new work bench.
    thanks guys!

Similar Threads

  1. Running main method class from another main class
    By tlrocketman in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 08:30 AM
  2. Main Class not found
    By Draugnar in forum New To Java
    Replies: 3
    Last Post: 01-09-2010, 03:12 AM
  3. main class not found
    By abhijit in forum Networking
    Replies: 3
    Last Post: 10-01-2009, 09:05 AM
  4. No main class found error
    By jhering1986 in forum New To Java
    Replies: 17
    Last Post: 03-28-2009, 02:34 AM
  5. Replies: 4
    Last Post: 01-01-2009, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •