i have the code for a simple mail transfer protocol but when i go to compile it in eclipse i get an error along the lines of cant find "main" class, program will now terminate, ive attached the code and would love it if someone could take a look and see if ive messed something up or if its just eclipse being a pain

Envelope.java

MailClient.java

Message.java

SMTPConnection.java

Recommended Answers

All 4 Replies

You have the main method in the MailClient.java. The only way I know to get that error is if you accidentally try to run a class with no main, so I would say try it again and make sure you run the MailClient class.

tried re-tuning the code, and i still receive the error, dont know if it will help but heres the exact print out i recieve

Exception in thread "main" java.lang.NoClassDefFoundError:
Caused by: java.lang.ClassNotFoundException:
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: . Program will exit.

Mattox is right. It's probably a problem in your run configuration. In particular check that your "main class" is MailClient in the run configurations dialog.

see if ... its just eclipse being a pain

The usual way that Eclipse is a "pain" is because it insists on helping you to have an error-free program and configuration. The chances of it being an Eclipse error rather than your own are roughly on a par with winning the lottery...

when i go to compile it in eclipse i get an error along the lines of cant find "main" class, program will now terminate

No. You do not get that error trying to compile anything. The distinction between compile-time errors and runtime errors is important.

thanks everyone, this had me incredibly frustrated. you were right my run configuration out of order

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.