I am installing eclipse in my mac and just try to test this code but show the error "Exception in thread "main" java.lang.NoClassDefFoundError" How i can solv or fixed it?
import java.util.*;
import java.io.*;
public class MyMain
{
public static void main(String[] args)
{
//System.out.println("Hello world");
}
}
In eclipse select this menu: Run > Run Configurations...
Then select the Run configuration of your test code.
In the Main class field check what's written there... If the class MyMain
has no package, Main class field should contain "MyMain".
This class should compile and work if the file is called MyMain.java. to compile it just run javac MyMain
from the same directory the file is located. Then run java MyMain
and you are good.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.