Solved

java.lang.ClassNotFoundException

Posted on 2012-04-02
3
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

695 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