Solved

java.lang.ClassNotFoundException

Posted on 2012-04-02
3
445 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

786 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