Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

java.lang.ClassNotFoundException

Posted on 2012-04-02
3
Medium Priority
?
461 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 36

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 36

Accepted Solution

by:
mccarl earned 1500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

824 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