954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

class issue

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

Attachments Envelope.java (2.26KB) MailClient.java (5.45KB) Message.java (2.4KB) SMTPConnection.java (4.39KB)
jrp370
Newbie Poster
19 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

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.

Mattox
Junior Poster in Training
57 posts since Jan 2011
Reputation Points: 10
Solved Threads: 15
 

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.

jrp370
Newbie Poster
19 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

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.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

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

jrp370
Newbie Poster
19 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: