Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Exception in thread "main" java.lang.NoClassDefFoundError: SendMailTLSDFC Date: Tue, 10 Apr 2012 10:16:37 -0700 (PDT) Organization: http://groups.google.com Lines: 37 Message-ID: <23393087.261.1334078197190.JavaMail.geo-discussion-forums@pbjk8> References: NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1334078197 22253 127.0.0.1 (10 Apr 2012 17:16:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 10 Apr 2012 17:16:37 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Received-Bytes: 2573 Xref: csiph.com comp.lang.java.programmer:13466 GGolf wrote: > deepak wrote: > > Hi, I have created a java [sic] file for sending a file to my mail. I a= m > > using mail.jar file. I am able to create .class file properly. But am > > unable to run this file using java command on command prompt. > > javac -cp D:\mail.jar SendMailTLSDFC.java > > above command is working properly. > > It creates 2 class as mentioned below > > SendMailTLSDFC$1.class > > SendMailTLSDFC.class > > > > but when i am trying to run following command I am getting an error. > > java -cp D:\mail.jar SendMailTLSDFC > > Exception in thread "main" java.lang.NoClassDefFoundError: > > SendMailTLSDFC >=20 > Did you try adding the current folder (.) to the classpath? In addition to GGolf's fine advice, which should solve that immediate probl= em, let me add a couple of extras: - http://sscce.org/ This fine discussion of the Simple, Self-Contained Compilable (Correct) Exa= mple (SSCCE) by Andrew Thompson will help you two ways. Creating an example= often reveals the problem to you before you post your question, and the ex= ample isolates your issue and makes it easier for people to respond sensibl= y. GGolf was clever to figure out your issue without an SSCCE. - Use packages. You put 'SendMailTLSDFC' in the default package, or "no-package" package. D= on't do that. Also, study the Java tutorial and other documentation on classpaths. --=20 Lew