Solved

java.lang.ClassNotFoundException

Posted on 2012-04-02
3
440 Views
Last Modified: 2012-04-23
I am getting  this exception even if I have exactly same top level public class name and the filename.


The  exception is:
Exception in thread "Main Thread" java.lang.NoClassDefFoundError:
...../common/util/email/PostEmail
Caused by: java.lang.ClassNotFoundException: com.breeze.common.util.email.PostEmail
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)




And the class def is:
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class PostEmail {

.......


public static void main(String[]args){
//class is instantiated and used here
}

}

Any help is appreciated!
Thanks
0
Comment
Question by:addisuc
  • 2
3 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 37798788
> Caused by: java.lang.ClassNotFoundException: com.breeze.common.util.email.PostEmail

It is looking for PostEmail to be in a package, and so you must have a line in your class def to say that it is in this package. So add the following line to the top of your PostEmail.java file...
package com.breeze.common.util.email;

Open in new window

0
 

Author Comment

by:addisuc
ID: 37801904
I already had that package import but issue was caused by some other(unknown). I just recreated my clearcase view and issue goes away.
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 37804282
> I already had that package import

It's not an "import" but a package declaration. You say that you already had it then you must have removed it (or not copied it) in what you posted in your original question, so that is why I said to use it.


> I just recreated my clearcase view and issue goes away.

Glad your issue is resolved!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now