简体   繁体   中英

How to solve Exception in thread “main” java.lang.NoClassDefFoundError

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM